DatePart

The DatePart() function retrieves a part from a date. For example, the year, the month, the week, the day, the hour, the minutes or the seconds.

This function is NOT SQL compatible. For more information about SQL compatibility, see our documentation.

Returns a number that is a part of a date. If the date is unknown then this function returns unknown.

Returns Unknown if one of the parameter values is unknown or outside the common valid date boundaries.

Syntax

DatePart(date, unit)

DatePart('2016-05-02T05:37:44', year) =>Result: 2016

DatePart() =>Result: unknown

Parameters

NameTypeRequiredDescription

date

date time

a date

unit

keyword

Date unit keyword

Possible values: year, month, week, day, hour, minute or second.

Last updated