Sunday, April 17, 2005

MySQL difference between dates in number of days

To get a date difference in days in Mysql version before 4.1 (where you can use the datediff() function instead), do the following to calculate date difference:

select (TO_DAYS(date1)-TO_DAYS(date2))


Emma said...

very useful...thnx

Anonymous said...

very good functions for difference

Kumar Pallav said...

SELECT DATEDIFF('2006-07-10','2006-06-01');