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

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"