MySQL DATE_SUB() function subtracts a specified time interval from a date.
DATE_SUB(date, INTERVAL expr type)
expr is the number of interval you want to subtract.
type can be one of :
MICROSECOND, SECOND, MINUTE, HOUR, DAY, WEEK, MONTH, QUARTER, YEAR, SECOND_MICROSECOND, MINUTE_MICROSECOND, MINUTE_SECOND, HOUR_MICROSECOND, HOUR_SECOND, HOUR_MINUTE, DAY_MICROSECOND, DAY_SECOND, DAY_MINUTE, DAY_HOUR, YEAR_MONTH
Query example
SELECT OrderId, DATE_SUB(OrderDate, INTERVAL 5 DAY) AS SubtractDate FROM Orders
No comments:
Post a Comment
Note: only a member of this blog may post a comment.