Please i need help on mysql on how to get last dates base on DATETIME

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

MySQL DATE_SUB() Function is what you want. Google is your friend on how to use it.

I will give you one example:

[php]SELECT DATE_SUB(yourColumnNameHere,INTERVAL 5 DAY) AS SubtractDate
FROM yourTableNameHere[/php]

thanks

Sponsor our Newsletter | Privacy Policy | Terms of Service