DATEPART Function
Returns an integer representing the specified part of a date. Weekdays are numbered starting with Monday as 1,
Tuesday as 2, and so forth until Sunday as 7.
Syntax
DATEPART(date-part, date)Parameters
-
date-part: text
One of the following predefined strings. Each date-part has abbreviated aliases that can be used in place of the longer names without affecting the behavior.year,yy,yyyyquarter,qq,qmonth,mm,mdayofyear,dy,yday,dd,dweek,wk,wwweekday,dwhour,hhminute,mi,nsecond,ss,smillisecond,ms
- date: text
A text value that can be parsed into a date/time.
Return Value
An integer representing the part of date that is specified by date-part.Example
PRINT DATEPART('month', '2016-07-23'); -- "7"
PRINT DATEPART('weekday', '2016-07-23'); -- "6"
PRINT DATEPART('dd', '2016-07-23'); -- "23"