DatePart
Extracts the specified date part from the given date.
See Sigma's Common Date Functions and Use Cases lab for more information about date functions, including use cases and exercises.
Usage
DatePart(precision, date, [timezone])
precision (required) Date part to be extracted. This can be “year”, "quarter", “month”, “week”, “day”, "weekday", “hour”, “minute”, “second”, “millisecond”, or "epoch".
date (required) Date or column of dates from which the date part is to be extracted.
timezone (optional) Name of IANA time zone to get the date part at (e.g., ”America/Los_Angeles”). When calculating a time zone, input dates are treated as UTC.
The output returned is presented in the organization's time zone. This may cause days, months, or years to appear offset if the specified time zone is ahead of the organization time zone. To view the output presented in the specified time zone, you can apply ConvertTimezone to it.
Example
DatePart("year", [Invoice Date])
- Extracts the year from each value in the column of 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).