|
The DATEADD function is used to add an interval to a date. This function is available in SQL Server.
The usage for the DATEADD function is
DATEADD (datepart, number, expression)
where the data type of <expression> is some type of date, time, or datetime. <number> is an integer (can be positive or negative). <datepart> can be one of the following:
| datepart | abbreviation |
| year | yy, yyyy |
| quarter | qq, q |
| month | mm, m |
| dayofyear | dy, y |
| day | dd, d |
| week | wk, ww |
| hour | hh |
| minute | mi, n |
| second | ss, s |
| millisecond | ms |
| microsecond | mcs |
| nanosecond | ns |
| TZoffset | tz |
| ISO_WEEK | isowk, isoww |
The result returned has the same data type as <expression>.
Example: The SQL statement
SELECT DATEADD(day, 10,'2000-01-05 00:05:00.000');
yields the following result:
'2000-01-15 00:05:00.000'
SQL DATEDIFF >>
Link to this page: If you find this page useful, we encourage you to link to this page. Simply copy and paste the code below to your website, blog, or profile.
Copyright 2010 1keydata.com. All Rights Reserved. Privacy Policy
|