Page 1 of 1

date closest to current date

Posted: Wed Mar 15, 2006 6:26 am
by phate
hi,
Im looking for tips on the best way to approach this. I have some dates in a mysql database and would like to return the date closest to the current date.
I thought maybe if I looked at the first date in the database and got the days between that date and the current date, continued through the rest of the table like that then the lowest number of days would be the date I want to return?
not sure if thats the best avenue to approach tbh, anyone see a better way?



cheers

Posted: Wed Mar 15, 2006 6:56 am
by anjanesh
You can try out with SUBDATE

Posted: Wed Mar 15, 2006 8:37 am
by a94060

Code: Select all

SELECT FROM my_table my_data ORDER BY DATE ASC
please fix because im pretty sure that it is in the wrong order.