# timestamp_trunc

> For the complete documentation index, see [llms.txt](https://docs.redpanda.com/llms.txt). Component-specific: [cloud-data-platform-full.txt](https://docs.redpanda.com/cloud-data-platform-full.txt)

---
title: timestamp_trunc
latest-operator-version: v26.1.4
latest-console-tag: v3.7.3
latest-connect-version: 4.93.0
latest-redpanda-tag: v26.1.9
docname: sql/sql-functions/timestamp-functions/timestamp-trunc
page-component-name: cloud-data-platform
page-version: master
page-component-version: master
page-component-title: Cloud
page-relative-src-path: sql/sql-functions/timestamp-functions/timestamp-trunc.adoc
page-edit-url: https://github.com/redpanda-data/cloud-docs/edit/main/modules/reference/pages/sql/sql-functions/timestamp-functions/timestamp-trunc.adoc
description: The `timestamp_trunc()` function rounds a timestamp to a specific day_time granularity, resulting in a truncated timestamp.
page-topic-type: reference
page-git-created-date: "2026-05-26"
page-git-modified-date: "2026-05-26"
---

<!-- Source: https://docs.redpanda.com/cloud-data-platform/reference/sql/sql-functions/timestamp-functions/timestamp-trunc.md -->

The `timestamp_trunc()` function rounds a timestamp to a specific `day_time` granularity, resulting in a truncated timestamp.

## [](#syntax)Syntax

```sql
SELECT TIMESTAMP_TRUNC(TIMESTAMP 'YYYY-MM-DD hour:min:sec', day_time);
```

`day_time` accepts these time values:

-   `SECOND`

-   `MINUTE`

-   `HOUR`

-   `DAY`

-   `MONTH`

-   `YEAR`


## [](#examples)Examples

### [](#timestamp_trunc-hour)`timestamp_trunc()` - hour

This example shows how to round the hour to the closest value:

```sql
SELECT TIMESTAMP_TRUNC(TIMESTAMP '2017-09-18 14:43:39.02322', HOUR) ;
```

The final result will display the current date and time in the timezone in which the query was issued:

```sql
+-----------------------------+
| f                           |
+-----------------------------+
| 2017-09-18 14:00:00.00000   |
+-----------------------------+
```

### [](#timestamp_trunc-minute)`timestamp_trunc()` - minute

This example truncates the specified timestamp into the nearest value:

```sql
SELECT TIMESTAMP_TRUNC(TIMESTAMP '2005-03-18 14:13:13', MINUTE) ;
```

The result is the truncated timestamp:

```sql
+-----------------------------+
| f                           |
+-----------------------------+
| 2005-03-18 14:13:00.00000   |
+-----------------------------+
```

### [](#basic-timestamp_trunc-function-year)Basic `timestamp_trunc()` function - year

Run this query to round the date to the closest value:

```sql
SELECT TIMESTAMP_TRUNC(TIMESTAMP '2023-03-04', YEAR);
```

The function will truncate the year and returns:

```sql
+-----------------------------+
| f                           |
+-----------------------------+
| 2023-01-01 00:00:00.00000   |
+-----------------------------+
```