Export (0) Print
Expand All
Expand Minimize

DATEADD (SQL Server Compact Edition)

Returns a new datetime value based on adding an interval to the specified date.


DATEADD (datepart ,number,date ) 

datepart

The parameter that specifies which part of the date to return as a new value. For more information, see the "Remarks" section later in this topic.

number

The value used to increment datepart. This is an expression of the exact numeric or approximate numeric data type categories, or types that can be implicitly converted to float. If you specify a value that is not an integer, the fractional part of the value is discarded. For example, if you specify day for datepart and 1.75 for number, the date is incremented by 1.

date

An expression that returns a value that can be implicitly converted to datetime, or is a Unicode character string in a date format. For more information about specifying dates, see datetime in Data Types.

If you specify only the last two digits of the year, values less than or equal to the last two digits of the value of the two digit year cutoff configuration option are in the same century as the cutoff year. Values greater than the last two digits of the value of this option are in the century that precedes the cutoff year. For example, if the two digit year cutoff is 2049 (the default), '49' is interpreted as 2049 and '50' is interpreted as 1950. To avoid ambiguity, use four-digit years.

datetime

The following table lists the datepart options and the abbreviations recognized by Microsoft SQL Server 2005 Compact Edition.

Datepart Abbreviations

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

The following example adds two months to the OrderDate values in the MyOrders table.

SELECT DATEADD(month, 2, OrderDate) FROM MyOrders
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft