> 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

```
DatePart(precision, date, [timezone])
```

The function has the following arguments:

|               |                                                                                                                                                                                                                                         |
| ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **precision** | Required <br /> 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 <br /> Date or column of dates where Sigma extracts the date part. <br /> 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) <br /> TZ identifier of the <a href="https://en.wikipedia.org/wiki/List_of_tz_database_time_zones" target="_blank">IANA time zone</a> 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 <a href="https://en.wikipedia.org/wiki/Unix_time" target="_blank">Unix epoch</a>.

## 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:

![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.](https://fdr-prod-docs-files-public.s3.us-east-1.amazonaws.com/sigma.docs.buildwithfern.com/aa6b1f8f80e19d5fb42948ca8e907f7ee24d40ed9c4a99c5044b815bab42768a/assets/docs-images/795b9947c78075faf2ea9247ffc9767c08b65d2aebfd52634c6dc205ba3c7320-Screenshot_2025-06-11_at_9.43.02_AM.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIA6KXJSKKNFOCF7G4B%2F20260727%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20260727T083103Z&X-Amz-Expires=604800&X-Amz-Signature=0f50e1edae3faecd50716bc14e6d3f59fa87e275382d00e93549cb215dba09a0&X-Amz-SignedHeaders=host&x-amz-checksum-mode=ENABLED&x-id=GetObject)

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:

![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.](https://fdr-prod-docs-files-public.s3.us-east-1.amazonaws.com/sigma.docs.buildwithfern.com/3ee33ff53f567975e427f3d4e2d2a0564065a79ba0b7e9551e441b8cc61a65f5/assets/docs-images/e7e148c3c9e0412a2e9a2c954ca79c5846204b435d088c76d10683dc4b1279f7-Screenshot_2025-06-11_at_9.54.41_AM.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIA6KXJSKKNFOCF7G4B%2F20260727%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20260727T083103Z&X-Amz-Expires=604800&X-Amz-Signature=f36f47f532216d6545f3951140a078712ef6b0457e6ed82cfeb318b556b0dcbe&X-Amz-SignedHeaders=host&x-amz-checksum-mode=ENABLED&x-id=GetObject)

## Related resources

* [ConvertTimezone](/docs/converttimezone)
* [Date](/docs/date)
* <a href="https://en.wikipedia.org/wiki/List_of_tz_database_time_zones" target="_blank" rel="noopener noreferrer">
    List of tz database time zones in Wikipedia
  </a>
* <a href="https://quickstarts.sigmacomputing.com/guide/common_date_functions/index.html" target="_blank" rel="noopener noreferrer">
    Quickstart: Common date functions and use cases
  </a>