# TIME\_PERIOD

| **Description** | The **`TIME_PERIOD`** function assigns a standard time period, such as day, week, month, quarter, or year, to a given date or datetime field. This is useful for organizing and aggregating data into consistent time intervals for analysis and reporting. |
| --------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Syntax**      | TIME\_PERIOD(**`date`**, "day"/"week"/"month"/"quarter"/"year")                                                                                                                                                                                             |

1. **`date`**: The date or datetime field for which you want to determine the time period.
2. **"day"**/**"week"**/**"month"**/**"quarter"**/**"year"**: Specifies the standard time period.

{% hint style="info" %}
The “week” time period groups from Monday to Sunday.
{% endhint %}

## Example

### Table

| Transaction   | Sale Date  |
| ------------- | ---------- |
| Transaction A | 2023-09-10 |
| Transaction B | 2023-08-25 |
| Transaction C | 2023-09-01 |

### Year

```
TIME_PERIOD(`Sale Date`, "year")
```

#### Results

| TIME\_PERIOD (text) |
| ------------------- |
| 2023                |
| 2023                |
| 2023                |

### Quarter

```
TIME_PERIOD(`Sale Date`, "quarter")
```

#### Results

| TIME\_PERIOD (text) |
| ------------------- |
| 2023-Q3             |
| 2023-Q3             |
| 2023-Q3             |

### Month

```
TIME_PERIOD(`Sale Date`, "month")
```

#### Results

| TIME\_PERIOD (text) |
| ------------------- |
| 2023-09             |
| 2023-08             |
| 2023-09             |

### Week

```
TIME_PERIOD(`Sale Date`, "week")
```

#### Results

| TIME\_PERIOD (text) |
| ------------------- |
| 2023-09-04          |
| 2023-08-21          |
| 2023-08-28          |

### Day

```
TIME_PERIOD(`Sale Date`, "day")
```

#### Results

| TIME\_PERIOD (text) |
| ------------------- |
| 2023-09-10          |
| 2023-08-25          |
| 2023-09-01          |
