Comparing 10-digit unix date with other date format in MySQL
If the date is stored in the database in 10-digit Unix format such as "1203683582" and you wish to do comparision with other date formats, do something like this:
SELECT * FROM mytable WHERE date BETWEEN UNIX_TIMESTAMP('2005-02-12') AND UNIX_TIMESTAMP('2010-01-01');Remember to use the date within UNIX_TIMESTAMP() function in yyyy-mm-dd international standard (this is a default format used by MySQL anyway). Passing the date in dd/mm/yyyy format does not work. If you do not pass the time in the UNIX_TIMESTAMP(), the time defaults to 00:00:00.
Comments
Post a Comment