part, n, dt_val)
Valid values for the part input include year, quarter, month, dayofyear, day, week, weekday, hour,
minute, second, millisecond, microsecond, and nanosecond. You can also specify the part in abbrevi-
ated form, such as yy instead of year. Refer to SQL Server Books Online for details.
The return type for a date and time input is the same type as the input’s type. If this function is
given a string literal as input, the output is DATETIME.
For example, the following code adds one year to February 12, 2009.
SELECT DATEADD(year, 1, '20090212');
This code returns the following output.
-----------------------
2010-02-12 00:00:00.000
The
DATEDIFF
Function
The DATEDIFF function returns the difference between two date and time values in terms of a speci-
fied date part.
Syntax
DATEDIFF(
Do'stlaringiz bilan baham: |