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

# TRUNC

> Truncates a date or timestamp to the specified unit and returns a DATE.

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

NULL value/unit yields NULL.

## Syntax

### Scalar

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

* Use TIMESTAMP with microsecond precision. TIMESTAMP values with nanosecond precision can raise a type error.

### Date (scalar)

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

* With E6 type conversion enabled, DATE input is first converted to TIMESTAMP. The result is DATE.
* Use DATE or TIMESTAMP with microsecond precision. TIMESTAMP literals with nanosecond precision currently raise a type error.

## Arguments

### Scalar

| Name | Type | Required | Description |
| - | - | - | - |
| value | TIMESTAMP | Yes | Temporal value. |
| unit | STRING | Yes | Truncation granularity. |

### Date

| Name | Type | Required | Description |
| - | - | - | - |
| value | DATE | Yes | Temporal value. |
| unit | STRING | Yes | Truncation granularity. |

## Returns

* Type: DATE
* NULL behavior: NULL value/unit yields NULL.

## Properties

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

## Usage notes

* Truncates the timestamp to the requested unit, then returns its date.

## Examples

### Date input truncation

* DATE input requires E6 type conversion to be enabled.

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT trunc(DATE '2024-03-15','MONTH') AS result;
```

| result |
| - |
| 2024-03-01 |

### Truncate to the start of a year

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT trunc(DATE '2024-08-19', 'YEAR') AS year_start;
```

| year\_start |
| - |
| 2024-01-01 |

## Limitations

* The result is DATE, even when query tools report TIMESTAMP. The returned value is not automatically converted to the reported type.
* Numeric TRUNC from other libraries is not an alias of this temporal form.
* TIMESTAMP literals with nanosecond precision currently raise a type error. Use the DATE form shown in the example or a supported microsecond TIMESTAMP.


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