I need to get the closest date to current date from a MySQL table.
This is my table:
id | date | name
1 | 2012-10-29 | test
2 | 2009-11-31 | test
So if the query was run today, it would return 1 | 2012-10-29 | test
Any help is much appreciated. Thanks
SELECT
*
FROM
your_table
ORDER BY
ABS(DATEDIFF(NOW(), `date`))
LIMIT 1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With