> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://help.sigmacomputing.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://help.sigmacomputing.com/_mcp/server.

# DatePart

> Use the Sigma DatePart function to extract a specified part of a date from a date value.

The **DatePart** function extracts a specified part of a date from a date value.

**DatePart** is a [date function](/docs/date-functions).

## Syntax

```sigma
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](/docs/date) function on the argument. |
| **timezone**  | (Optional)  TZ identifier of the [IANA time zone](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) 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](/docs/account-time-zone).
* In the `precision` argument, `epoch` refers to the [Unix epoch](https://en.wikipedia.org/wiki/Unix_time).

## Examples

```sigma
DatePart("year", [Invoice Date])
```

Extracts the year from each value in the *Invoice Date* column.

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

Returns `2`, the week number of this date in the year.

```sigma
DatePart("year", [Invoice Date])
```

```sigma
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`.

```sigma
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:

![Table with a Date column, Year of Date, Quarter of Date, Month of Date, Week of Date, Day of Date, and Weekday of Date columns extracted.](/_fern-img/aa6b1f8f80e19d5fb42948ca8e907f7ee24d40ed9c4a99c5044b815bab42768a.webp)

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).

```sigma
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:

![Table with a Date column, Year of Date, Hour of Date, Minute of Date, Second of Date, Millisecond of Date, and Epoch of Date columns extracted.](/_fern-img/3ee33ff53f567975e427f3d4e2d2a0564065a79ba0b7e9551e441b8cc61a65f5.webp)

## Related resources

* [ConvertTimezone](/docs/converttimezone)
* [Date](/docs/date)
* [List of tz database time zones in Wikipedia](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones)
* [Quickstart: Common date functions and use cases](https://quickstarts.sigmacomputing.com/guide/common_date_functions/index.html)