Date Truncate Function

The date_trunc function supports the given below units. The examples in the table use timestamp 2000-08-05T09:05:10 as an input.

unitTruncated example value

second

2000-08-05T09:05:10

minute

2000-08-05T09:05:00

hour

2000-08-05T09:00:00

day

2000-08-05T00:00:00

week

2000-07-31T00:00:00

month

2000-08-01T00:00:00

quarter

2000-07-01T00:00:00

year

2000-01-01T00:00:00

DATE_TRUNC( unit, <datetime_expr> )

Returns the input expression truncated to a given unit (refer above table).

 > select date_trunc('year' , '2022-03-23');
 '2022-01-01'

Last updated