Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.tools -> fiscal year code
Hi!
I'm fairly new to Oracle block structure programming, and was wondering if someone could help me clarify my code to dynamically generate a table filled with fiscal year dates based on user input. I have the algorithm, but my syntax is probably all wrong. For space saving, where I would do an "insert into..." command, I have written fiscal_begin(&xMonth) or fiscal_end(&xMonth).
I will also have to put in a loop to go back a whole year, but that can be added later. Right now, I just to implement this base case code correctly, and then get fancy.
accept xDate prompt Enter fiscal month (MON-YYYY):
set xMonth = to_date('&xDate', 'MON-YYYY')
BEGIN
if to_char(&xMonth, 'MON') = 'JAN'
then fiscal_begin(&xMonth) = last_day(add_months(&xMonth,-1)+1
else BEGIN
if ((to_char(last_day(add_months(&xMonth,-1)+1, 'DAY') = 'SATURDAY') or
(to_char(last_day(add_months(&xMonth,-1)+1, 'DAY') = 'SUNDAY'))
then fiscal_begin(&xMonth) = next_day(last_day(add_months(&xMonth,-1)), 'MONDAY') else fiscal_begin(&xMonth)=next_day(last_day(add_months(&xMonth,-1)-7), 'MONDAY') end if END
if ((to_char(last_day(&xMonth)+1, 'DAY') = 'SATURDAY') or
(to_char(last_day(&xMonth)+1, 'DAY') = 'SUNDAY'))
then fiscal_end(&xMonth) = next_day(last_day(&xMonth)+3,'SUNDAY') else fiscal_begin(&xMonth)=next_day(last_day(&xMonth),'SUNDAY') end if END
If anyone can help (or simplify this algorithm), I would really, really appreciate it.
Thank you very much,
Eric Bycer Received on Thu Sep 28 2000 - 21:11:30 CDT
![]() |
![]() |