SQL Reference
...
SQL Functions
Timestamp Functions
TIMESTAMP_TRUNC
7min
The TIMESTAMP_TRUNC() function rounds a timestamp to a specific day_time granularity, resulting in a truncated timestamp.

day_time can be replaced with various time values as follows:
- SECOND
- MINUTE
- HOUR
- DAY
- MONTH
- YEAR
The following example shows how to round the hour to the closest value:

The final result will display the current date and time in your timezone:

Here we will truncate the specified timestamp into the nearest value:

The result will return the truncated timestamp as shown below:

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

The function will truncate the year and return the following result:


Updated 09 Oct 2023

Did this page help you?