I would like to retrive a TODAY'S data from the database, but I don't know how to do it. I would actually want to get the data from NOT the past 24 hours, I just want today's data (so based on the actual server time).
I would also like to get data which was yesterday. Can anyone help me how to do it?
Sample code:
"SELECT id FROM folk WHERE time = ???"
Thank you in advance!
I think you are looking for this:
"SELECT id FROM folk WHERE DATE(time) = CURDATE()"
time must be a field in you table that holds a reference to the row.
update
To get yesterdays additions:
"SELECT id FROM folk WHERE DATE(time) = CURDATE() - 1"
update 2
To get all additions this month:
"SELECT id FROM folk
WHERE MONTH(time) = MONTH(NOW()) AND YEAR(time) = YEAR(NOW())"
reference: http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html
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