Extract the specified date part, e.g. “month”, from the given date.

Usage

DatePart(precision, date, [timezone])

precision (required) Date part to be extracted, chosen from “year”, "quarter", “month”, “week”, “day”, "weekday", “hour”, “minute”, “second”, “millisecond”, and "epoch".

date (required) Date from which date part is to be extracted.

timezone (optional) Name of IANA timezone to get the date part at, e.g.”America/Los_Angeles”. When calculating a timezone, input dates are treated as UTC. Note: The output returned will be presented in the organization timezone. This may cause days, months, or years to appear offset if the specified timezone is ahead of the organization timezone. If you want to see the output presented in the specified timezone, you can apply ConvertTimezone to it.

Example

DatePart("year", [Invoice Date])

Extracts the year from the invoice dates.

DatePart("week", Date("2007-01-10 10:00:00"))

Returns 2, the week number of this date.
Weeks in Sigma are considered to start on Sunday.