|
Transact-SQL User's Guide
|
Add date interval: dateadd
The dateadd function adds an interval (specified
as a integer) to a date you specify. For example, if the publication
dates of all the books in the titles table
slipped three days, you could get the new publication dates with
this statement:
select dateadd(day, 3, pubdate)
from titles
-------------------
Jun 15 1986 12:00AM
Jun 12 1988 12:00AM
Jul 3 1985 12:00AM
Jun 25 1987 12:00AM
Jun 12 1989 12:00AM
Jun 21 1985 12:00AM
Jul 6 1997 1:43PM
Jul 3 1986 12:00AM
Jun 15 1987 12:00AM
Jul 6 1997 1:43PM
Oct 24 1990 12:00AM
Jun 18 1989 12:00AM
Oct 8 1990 12:00AM
Jun 15 1988 12:00AM
Jun 15 1988 12:00AM
Oct 24 1990 12:00AM
Jun 15 1985 12:00AM
Jun 15 1987 12:00AM
(18 rows affected)
If the date argument is given as a smalldatetime,
the result is also a smalldatetime. You can
use dateadd to add seconds or milliseconds to
a smalldatetime, but it is meaningful only
if the result date returned by dateadd changes
by at least one minute.