I want to select the following from mysql
Last 12 hours
Last 24 hours
last 7 days
last 1 month
I will be glad with some one help me
For the last 12 hours, it'd be something like this:
SELECT * FROM some_table WHERE some_datetime_field >= SUBDATE(NOW(), INTERVAL 12 HOUR);
For information on the INTERVAL unit argument, see the discussion for DATE_ADD().
alternatively
SELECT * FROM some_table WHERE some_datetime_field >= NOW() - INTERVAL 12 HOUR