MySQL DATE_SUB() Function
MySQL Date Functions
Definition and Usage
The DATE_SUB() function subtracts a specified time interval from a
date.
Syntax
DATE_SUB(date,INTERVAL expr type)
|
Where date is a valid date expression and expr is the number of interval
you want to subtract.
type can be one of the following:
Type Value |
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 |
Example
Assume we have the following "Orders" table:
OrderId |
ProductName |
OrderDate |
1 |
Jarlsberg Cheese |
2008-11-11 13:23:44.657 |
Now we want to subtract 5 days from the "OrderDate" date.
We use the following SELECT statement:
SELECT OrderId,DATE_SUB(OrderDate,INTERVAL 5 DAY) AS SubtractDate
FROM Orders
|
Result:
OrderId | SubtractDate |
1 | 2008-11-06 13:23:44.657 |
MySQL Date Functions
Learn how your website performs under various load conditions
|
|
WAPT
is a load, stress and performance testing tool for websites and web-based applications.
In contrast to "800-pound gorilla" load testing tools, it is designed to minimize the learning
curve and give you an ability to create a heavy load from a regular workstation.
WAPT is able to generate up to 3000 simultaneously acting virtual users using standard hardware configuration.
Virtual users in each profile are fully customizable. Basic and NTLM authentication methods are supported.
Graphs and reports are shown in real-time at different levels of detail, thus helping to manage the testing process.
Download the free 30-day trial!
|
|