> ## Documentation Index
> Fetch the complete documentation index at: https://docs.e6data.com/llms.txt
> Use this file to discover all available pages before exploring further.

# DATE_TRUNC

> Truncates a timestamp to a chosen granularity.

<div className="e6-meta"><span className="e6-eyebrow e6-eyebrow--quiet">Scalar function</span></div>

Returns NULL if the value or granularity is NULL. Invalid granularity values normally return NULL, including in format columns, but some constant STRING representations can raise an error.

## Syntax

### Scalar

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
date_trunc(unit, value)
```

## Arguments

| Name | Type | Required | Description |
| - | - | - | - |
| unit | STRING | Yes | Truncation granularity. microsecond, millisecond, second, minute, hour, day, week, month, quarter, year; aliases yyyy/yy/yr, mm/mon/months, dd/days, hh/hours, mi/minutes, seconds, qq/quarters, wk/weeks, milliseconds, us/microseconds. Case-insensitive and trimmed. |
| value | TIMESTAMP | Yes | Timestamp to truncate. |

## Returns

* Type: TIMESTAMP
* NULL behavior: Returns NULL if the value or granularity is NULL. Invalid granularity values normally return NULL, including in format columns, but some constant STRING representations can raise an error.

## Properties

| Property | Value |
| - | - |
| Deterministic | Yes |
| Exact result | Yes |

## Usage notes

* Unit matching accepts Spark aliases such as YY/YYYY, MM/MON, DD, plus MICROSECOND/MILLISECOND and standard granularities.
* Truncation uses the timestamp’s stored clock values and preserves its time-zone label.

## Examples

### Basic example

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT date_trunc('month',TIMESTAMP '2024-03-15 10:30:45') AS result;
```

| result |
| - |
| 2024-03-01 00:00:00 |

### Truncate to the start of an hour

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT date_trunc('hour', TIMESTAMP '2024-03-15 10:30:45') AS hour_start;
```

| hour\_start |
| - |
| 2024-03-15 10:00:00 |

## Limitations

* Truncation uses the stored UTC clock time and preserves the input’s time-zone label. Day, month, and year boundaries therefore follow UTC rather than the named time zone’s local clock.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.