Need some help using date functions to perform quarter calculations. The input is in quarter type format: "Quarter #, YYYY". Based on the input quarter, I need to calculate the previous quarter information.
Based on the input quarter, calculate the previous quarter:
Input: "Quarter 1, 2001"
Output: "Quarter 4, 2000"
or Input: "Quarter 3, 2001"
out: "Quarter 2, 2001"
note: fiscal year starts in November. Therefore, Quarter 1 includes months of Nov, Dec, Jan (in different calendar yrs).
Thanks for your help!
You could probably just use a decode for this. The following sql*plus script will prompt for a string in the format described and convert it:
col Quarter new_value quarter
col Year new_value year
accept qstring prompt 'String: '
select substr('&qstring', 9,1) quarter, substr('&qstring', 12,4) year
Click Here to Expand Forum to Full Width