only1perky Posted September 15, 2009 Share Posted September 15, 2009 Hi Guys, I have a mysql table that stores date and time in a field in the format '19-08-09 11:56', I need to use a query to get the date that is closest to the current date, how would I do so? I've tried using SELECT MAX(datetime) but for some reason this is not pulling the most recent field. Any help would be appreciated. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/174339-query-to-find-the-most-recent-date/ Share on other sites More sharing options...
Maq Posted September 15, 2009 Share Posted September 15, 2009 MAX() should work on a datetime field. Is your column really called 'datetime'? It would be nice if you showed us the entire query. This will work as well: SELECT `datetime` FROM table ORDER BY `datetime` DESC Quote Link to comment https://forums.phpfreaks.com/topic/174339-query-to-find-the-most-recent-date/#findComment-918991 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.