Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.tools -> fiscal year code

fiscal year code

From: Eric Bycer <ebycer_at_mediaone.net>
Date: Fri, 29 Sep 2000 02:11:30 GMT
Message-ID: <B5F97396.BC%ebycer@mediaone.net>

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

end if
if to_char(&xMonth, 'MON') = 'DEC'
then fiscal_end(&xMonth) = last_day(&xMonth) else BEGIN
     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

end if

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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US