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:
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: