Date and Time Functions (Transact-SQL)
The document is archived and information here might be outdated

Date and Time Functions (Transact-SQL)

The following scalar functions perform an operation on a date and time input value and return a string, numeric, or date and time value.

The Transact-SQL date and time functions and their determinism property are listed in the following table. For more information about function determinism, see Deterministic and Nondeterministic Functions.

Function Determinism

DATEADD

Deterministic

DATEDIFF

Deterministic

DATENAME

Nondeterministic

DATEPART

Deterministic except when used as DATEPART (dw, date) or DATEPART (wk,ww, date ). dw, the weekday datepart, depends on the value that is set by SET DATEFIRST, which sets the first day of the week. The week (wk, ww) datepart reflects changes that are made to SET DATEFIRST. January 1 of any year defines the starting number for the week datepart, for example: DATEPART(wk, 'Jan 1, xxxx') = 1, where xxxx is any year.

DAY

Deterministic

GETDATE

Nondeterministic

GETUTCDATE

Nondeterministic

MONTH

Deterministic

YEAR

Deterministic

Show:
© 2016 Microsoft