date_trunc Function
date_trunc
returns a timestamp
with the “floor value” of the specified time component, i.e. the largest time component less than or equal to the provided value.
Signatures
Parameter | Type | Description |
---|---|---|
ts_val | timestamp , timestamp with time zone |
The value you want to truncate. |
Return value
date_trunc
returns a timestamp
value.
Examples
SELECT date_trunc('hour', TIMESTAMP '2019-11-26 15:56:46.241150') AS hour_trunc;
hour_trunc
-------------------------------
2019-11-26 15:00:00.000000000
```sql SELECT date_trunc('year', TIMESTAMP '2019-11-26 15:56:46.241150') AS year_trunc; ``` ```nofmt year_trunc ------------------------------- 2019-01-01 00:00:00.000000000 ```