DATE_TRUNC
Syntax
%%{init: {
'theme': 'base',
'flowchart': { 'padding': '7', 'nodeSpacing': '20', 'rankSpacing': '20' },
'themeVariables': {
'fontSize': '11px',
'fontFamily': 'Arial'
}
}}%%
flowchart LR
Start((START)) --> DATE_TRUNC[DATE_TRUNC]:::quoted
DATE_TRUNC --> End((END))
Purpose
The DATE_TRUNC SQL function returns the truncated value of a datetime.
See also DATE_CEIL, DATE_FLOOR and DATE_ROUND.
Parameters:
- Precision (
varchar2): one ofmillenium,century,decade,year,quarter,month,week,day,hour,minute,second,millisecondsandmicroseconds. A week starts on Sunday. - Date/time (
datetime): the date/time to truncate.
Returns: the truncated with the defined precision of the input date/time as datetime. The original value is returned when an unlisted precision is specified.
Examples
The following example retrieves the truncated value of the system time on year basis:
select date_trunc('year', to_date('19870315', 'YYYYMMDD'))
-------------------
01-01-1987 00:00:00
The following example retrieves the truncated value of a date on month basis:
select date_trunc('month', to_date('20990317', 'YYYYMMDD'))
-------------------
01-03-2099 00:00:00
The following example retrieves the truncated value of Thursday 1 October 2026 on week basis; a week starts on Sunday:
select date_trunc('week', to_date('20261001', 'YYYYMMDD'))
-------------------
27-09-2026 00:00:00