I think there was a function extract(quarter from date) in oracle sql to fetch the quarter for a given date. However the Oracle SQL 19c documentation here does not show the presence of quarter
anymore.
I even tried running the code -
select extract(quarter from to_date('15/09/2021','DD/MM/YYYY')) as Q from dual;
The expected result is -
+---+
| Q|
+---+
| 3|
+---+
Instead it gives an error
ORA-00907 missing right parenthesis
though it runs fine when quarter
is replaced by month
or year
. What is the current way to fetch quarter
given a date in Oracle SQL 19c?
extract
. Even though in principle there is no reason not to have it, I believeextract
is based strictly on the internal data format Oracle uses for dates. That format has separate bytes for year, month, day, etc. - but not for quarter, or for week, or other calendar units. Those are all calculated, and are not options toextract
.