Get entries for latest mysql timestamp

How do I get all the records for the last date. The date indicated in my db is called recordEntryDate, and it is in this form. 2010-01-26 13:28:35

Lang: php DB: mysql

+5
source share
3 answers

You can do it:

SELECT *
FROM table1
WHERE DATE(recordEntryDate) = (
   SELECT MAX(DATE(recordEntryDate))
   FROM table1
)

Please note that this query will not be able to use the index on recordEntryDate. If you have many lines, this similar query might be faster for you:

SELECT *
FROM table1
WHERE recordEntryDate >= (
   SELECT DATE(MAX(recordEntryDate))
   FROM table1
)
+8
source
SELECT * 
FROM table1 
WHERE DATE(recordEntryDate) = ( 
   SELECT MAX((recordEntryDate))
   FROM table1 
) 

No need DATEthere.

+2
source

Or if you want our results to be

SELECT * 
FROM  table 
WHERE  recordEntryDate > DATE( NOW( ) ) 
0
source

All Articles