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
TIMESTAMP_TRUNC()
- HourThe 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:
TIMESTAMP_TRUNC()
- MinuteHere we will truncate the specified timestamp into the nearest value:
The result will return the truncated timestamp as shown below:
TIMESTAMP_TRUNC()
function - YearRun the following query to round the date to the closest value:
The function will truncate the year and return the following result:
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
TIMESTAMP_TRUNC()
- HourThe 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:
TIMESTAMP_TRUNC()
- MinuteHere we will truncate the specified timestamp into the nearest value:
The result will return the truncated timestamp as shown below:
TIMESTAMP_TRUNC()
function - YearRun the following query to round the date to the closest value:
The function will truncate the year and return the following result: