# DatePart

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

Analytics Pro returns the result(s) in your organization's time zone. This may cause days, months, or years to appear offset, if the specified time zone is ahead of the organization's time zone. To view the output presented in the specified time zone, apply the [converttimezone](https://support.meetuma.ai/uma-knowledgebase/data-and-reporting/analytics-pro/functions/date-functions/converttimezone "mention") function.

### Syntax

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

The function has the following arguments:

|               |                                                                                                                                                                                                                                                              |
| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **precision** | <p>Required<br>The date part extracted. Can be one of “year”, "quarter", “month”, “week”, “day”, "weekday", “hour”, “minute”, “second”, “millisecond”, or "epoch".</p>                                                                                       |
| **date**      | <p>Required<br>Date or column of dates where Analytics Pro extracts the date part.<br>The value must be a date. If the column is not in the appropriate format, use the <a data-mention href="../type-functions/date">date</a> function on the argument.</p> |
| **timezone**  | <p>Optional<br>TZ identifier of the <a href="https://en.wikipedia.org/wiki/List_of_tz_database_time_zones">IANA time zone</a> for the date part. For example, ”America/Los\_Angeles”. If omitted, defaults to UTC.</p>                                       |

### Examples

`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 Analytics Pro start on Sunday, by default.

```
DatePart("year", Date([Date]))DatePart("quarter", Date([Date]))DatePart("month", Date([Date]))
DatePart("week", Date([Date]))DatePart("day", Date([Date]))DatePart("weekday", Date([Date]))
```

The **DatePart** function returns the following values for the **Date** column:

<figure><img src="https://files.readme.io/e3a131d-function-datepart-example1.png" alt=""><figcaption></figcaption></figure>

```
DatePart("year", Date([Date]))
DatePart("hour", Date([Date]))DatePart("minute", Date([Date]))DatePart("second", Date([Date]))DatePart("millisecond", Date([Date]))DatePart("epoch", Date([Date]))
```
