Connor and Chris will both be at AI World from October 12 to October 17 , the premier Oracle conference of 2025. If you're in Vegas, please come say Hi or pop into our sessions
Thanks for the question.
Asked: August 31, 2018 - 5:11 pm UTC
Last updated: September 05, 2018 - 4:49 am UTC
Version: ORACLE 12C
Viewed 1000+ times
SQL> create or replace 2 procedure show_month(p_input varchar2) is 3 l_mth_num int; 4 l_mth_qtr int; 5 begin 6 l_mth_num := to_number(to_char(to_date(p_input,'MONTH'),'MM')); 7 l_mth_qtr := to_number(to_char(to_date(p_input,'MONTH'),'Q')); 8 9 dbms_output.put_line(p_input||' is month '||l_mth_num); 10 dbms_output.put_line(p_input||' is quarter '||l_mth_qtr); 11 end; 12 / Procedure created. SQL> SQL> SQL> exec show_month('JANUARY'); JANUARY is month 1 JANUARY is quarter 1 PL/SQL procedure successfully completed. SQL> exec show_month('MARCH'); MARCH is month 3 MARCH is quarter 1 PL/SQL procedure successfully completed. SQL> exec show_month('AUGUST'); AUGUST is month 8 AUGUST is quarter 3 PL/SQL procedure successfully completed.
A reader, September 04, 2018 - 12:23 pm UTC
Check out more PL/SQL tutorials on our LiveSQL tool.
PL/SQL reference manual from the Oracle documentation library