MySQL tip TIMESTAMPDIFF
Thanks for my college CY.
UNIX_TIMESTAMP(birthday) is not working when birthday is before 1970.
I should use TIMESTAMPDIFF(DAY, '1900-01-01', birthday) to get the DAY or SECOND
http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_timestampdiff
in Perl, we can do:
UNIX_TIMESTAMP(birthday) is not working when birthday is before 1970.
I should use TIMESTAMPDIFF(DAY, '1900-01-01', birthday) to get the DAY or SECOND
mysql> select TIMESTAMPDIFF(DAY, '1900-01-01', '1998-05-01');
+------------------------------------------------+
| TIMESTAMPDIFF(DAY, '1900-01-01', '1998-05-01') |
+------------------------------------------------+
| 35914 |
+------------------------------------------------+http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_timestampdiff
in Perl, we can do:
use Date::Calc qw/Delta_Days/;
print Delta_Days(1900,1,1, 1998,5,1);
^Z
35914Labels: MySQL
0 Comments:
Post a Comment
Links to this post:
Create a Link
<< Home