DATEPART

<< Click to Display Table of Contents >>

 

DATEPART

Returns the value of the time unit indicated by the @datePart parameter corresponding to the date specified in the @date parameter.

 

Syntax

DATEPART(@datePart, @date)

 

Parameters

@datePart: Indication of the date part, or time unit, to return. Possible values for this parameter are described on the next table

@date: Date to parse

 

Possible values for the @datePart parameter

Value

Description

year, yyyy, or yy

Returns the year from a date

quarter, qq, or q

Returns the quarter from a date

month, mm, or m

Returns the month from a date

dayofyear, dy, or y

Returns the day of the year from a date

day, dd, or d

Returns the day of the month from a date

week, wk, or ww

Returns the number of the week of a year from a date

weekday or dw

Returns the number of a week day from a date

hour or hh

Returns the hour from a date

minute, mi, or n

Returns the minutes from a date

second, ss, or s

Returns the seconds from a date

millisecond or ms

Returns the milliseconds from a date

microsecond or mcs

Returns the microseconds from a date

nanosecond or ns

Returns the nanoseconds from a date

iso_week, isowk, or isoww

Returns the number of the week of a year in ISO system from a date. NOTE: This value is not available for functions DATEADD and DATEDIFF

Was this page useful?