Posted in

DATEADD (Transact-SQL)

This function adds a number (a signed integer) to a datepart of an input date, and returns a modified date/time value. For example, you can use this function to find the date that is 7000 minutes from today: number = 7000, datepart = minute, date = today.

Syntax

DATEADD (datepart , number , date )

Arguments

datepart

The part of date to which DATEADD adds an integer number. This table lists all valid datepart arguments.

datepart Abbreviations
year yyyyyy
quarter qqq
month mmm
dayofyear dyy
day ddd
week wkww
weekday dww
hour hh
minute min
second sss
millisecond ms
microsecond mcs
nanosecond ns

 

number

An expression that can resolve to an int that DATEADD adds to a datepart of dateDATEADD accepts user-defined variable values for numberDATEADD truncates a specified number value that has a decimal fraction. It will not round the number value in this situation.

date

An expression that can resolve to one of the following values:

  • date
  • datetime
  • datetimeoffset
  • datetime2
  • smalldatetime
  • time

 

Leave a Reply

Your email address will not be published. Required fields are marked *