0

For some reason, when I insert '2015041200000000' into an INT(20) field I turns into '2147483647'...

How is this possible?

I'm doing this because I want to format the auto incremented ID to YYYYMMDDXXXXXXXX with php.

Thanks in advance

1 Answer 1

2

2147483647 is far from a "random value". It's the maximum value of a signed 32-bit integer, so an INT data type is not enough to store the value you're trying to use. You may want to try BIGINT instead.

https://en.wikipedia.org/wiki/2147483647#In_computing https://dev.mysql.com/doc/refman/5.1/en/integer-types.html

Sign up to request clarification or add additional context in comments.

2 Comments

Ah, I should have known that. More so because nothing is truly random when programming. It worked perfectly.
One more question, is this a good way to generate transaction id's? Having an auto increment field and then pulling the insert id and formatting that and reinserting it?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.