[wd_asp elements=’search’ ratio=’100%’ id=1]

MySQL DATE_SUB Function – Date minus time

2nd June 2014

MySql

mysql codehaven category

Assume we have the following Orders

OrderId: 1
ProductName : OrderDate1
Cheese: 2008-11-11 13:23:44
Now we want to subtract 5 days from the OrderDate date.We use the following SELECT statement:
SELECT OrderId,DATE_SUBOrderDate,INTERVAL 5 DAY AS SubtractDateFROM Orders
Result: 2008-11-06 13:23:44