DatePart
The DatePart function extracts a specified part of a date from a date value.
DatePart is a date function.
Syntax
DatePart(precision, date, [timezone])
The function has the following arguments:
| precision | Required The date part extracted. Can be one of “year”, "quarter", “month”, “week”, “day”, "weekday", "day_of_year", “hour”, “minute”, “second”, “millisecond”, or "epoch". |
| date | Required Date or column of dates where Sigma extracts the date part. The value must be a date. If the column is not in the appropriate format, use the Date function on the argument. |
| timezone | (Optional) TZ identifier of the IANA time zone for the date part. For example, ”America/Los_Angeles”. If omitted, defaults to UTC. |
Notes
- Sigma interprets date values in your organization's time zone by default. In the DatePart function, you can optionally specify a different time zone using the timezone argument. If your organization's time zone is not the same as the time zone of the date values in your data warehouse, the output might be offset. For more information, see Account time zone.
- In the
precisionargument,epochrefers to the Unix epoch.
Examples
DatePart("year", [Invoice Date])
Extracts the year from each value in the Invoice Date column.
DatePart("week", Date("2007-01-10 10:00:00"))
Returns 2, the week number of this date in the year.
DatePart("year", [Invoice Date])
DatePart("hour", [Date], "America/New_York")
Extracts the hour from each value in the [Date] column, converted to Eastern time. In an organization set to the time zone UTC, a row with a [Date] value 2025-03-11 00:00:00 returns 20.
DatePart("year", [Date])
DatePart("quarter", [Date])
DatePart("month", [Date])
DatePart("week", [Date])
DatePart("day", [Date])
DatePart("weekday", [Date])
DatePart("day_of_year", [Date])
Based on the formulas above, the DatePart function returns the following values for the Date column:
In the precision argument, day returns the day of the month (1-31), weekday returns the day of the week (1-7, beginning on Sunday), and day_of_year returns the day of the year (1-366, accounting for leap years).
DatePart("year", [Date])
DatePart("hour", [Date])
DatePart("minute", [Date])
DatePart("second", [Date])
DatePart("millisecond", [Date])
DatePart("epoch", [Date])
Based on the formulas above, the DatePart function returns the following values for the Date column:

Updated 14 days ago
