05 March 2008
This post may be outdated due to it was written on 2008. The links may be broken. The code may be not working anymore. Leave comments if needed.
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
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
35914


blog comments powered by Disqus