date closest to current date

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
phate
Forum Newbie
Posts: 1
Joined: Wed Mar 15, 2006 6:17 am

date closest to current date

Post 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
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

You can try out with SUBDATE
User avatar
a94060
Forum Regular
Posts: 543
Joined: Fri Feb 10, 2006 4:53 pm

Post 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.
Post Reply