DATEPART
Syntax
%%{init: {
'theme': 'base',
'flowchart': { 'padding': '7', 'nodeSpacing': '20', 'rankSpacing': '20' },
'themeVariables': {
'fontSize': '11px',
'fontFamily': 'Arial'
}
}}%%
flowchart LR
Start((START)) --> DATEPART[DATEPART]:::quoted
DATEPART --> End((END))
Purpose
The DATEPART SQL function gets the specified datepart from a datetime.
Parameters:
- Date part (
varchar2): the part to be extracted, chosen fromyear,yyyy,yy,quarter,qq,q,month,mm,m,day,dy,y,week,ww,wk,hour,hh,minute,mi,n,second,ss,s,millisecond,ms,microsecond,mcs,nanosecondandns. - date (
datetime): the value to get the part from.
Returns: the value of the selected part of the date/time as int32. null is returned when a non-existing date part is chosen.
Examples
The following example retrieves the month part of a date:
select datepart('month', to_date('2016-12-31', 'YYYY-MM-DD'))
-------------------
12
The following example retrieves the week part of a date:
select datepart('week', to_date('2016-12-31', 'YYYY-MM-DD'))
-------------------
52