Simple question:
I have 2 Mysql servers and I run this query in both:
select unix_timestamp('0000-00-00 00:00:00');
Results:
On server 1:
mysql> select unix_timestamp('0000-00-00 00:00:00');
+---------------------------------------+
| unix_timestamp('0000-00-00 00:00:00') |
+---------------------------------------+
| NULL |
+---------------------------------------+
On server 2:
mysql> select unix_timestamp('0000-00-00 00:00:00');
+---------------------------------------+
| unix_timestamp('0000-00-00 00:00:00') |
+---------------------------------------+
| 0 |
+---------------------------------------+
I need the 0 in both cases.
Why? Any suggestions?
Thanks!
Tomas Creemers :
I am going to assume that your two servers do not run the same MySQL version.\n\nMySQL returns 0 when you pass a timestamp to UNIX_TIMESTAMP() that is out of range.\n\nMariaDB (the MySQL fork that is currently used by some Linux distributions as the default) returns NULL in the same situations.\n\nA timestamp is out of range for UNIX time if it is before 1970-01-01 00:00:00 or after 2038-01-19 03:14:08. This is because it is stored as a 32-bit unsigned integer. 1970-01-01 00:00:00 is 0 and since it is unsigned it cannot express anything before that. On 2038-01-19 03:14:08 the integer will reach its maximum value and anything after that also cannot be expressed as a UNIX timestamp. (A solution that is already in place on some systems is to use a 64-bit integer instead, giving us several hundred thousand years extra.)\n\nSee the MySQL documentation for UNIX_TIMESTAMP() and a MariaDB-related article about this problem.",
2013-08-08T22:24:21