DATE_TRUNC()
function truncates a timestamp, timestamp with time zone or interval value to the specified precision,
effectively rounding down the value to the start of the given time unit. The return type matches the input type.
DATE_TRUNC()
function is as follows:
field
: The unit of time used to truncate the source
value. It accepts text
inputs and is case-insensitivesource
: The value you want to truncate. It can be INTERVAL
, TIMESTAMP
or TIMESTAMP WITH TIME ZONE
time_zone
(applicable for the second syntax option): The time zone for the operation. It accepts text
inputDATE_TRUNC()
syntax.
microseconds
milliseconds
second
minute
hour
day
week
month
quarter
year
decade
century
millennium
microseconds
and milliseconds
are supported only for interval types.