View previous topic :: View next topic
|
Author |
Message |
sskpen
New User
Joined: 30 Aug 2006 Posts: 14
|
|
|
|
I got a requirement where I need to read a field in file in MM/YY format and I should get all the past preceding 11 months considering the month in the file(MM/YY) as current month can someone give logic for this? |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
define a table as:
Code: |
01 DUH-SUBSCRIPTS.
05 DUH-FIRST-MONTH PIC S9(04) COMP.
05 DUH-LAST-MONTH PIC S9(04) COMP.
01 DUH-MONTH-DEFINITION.
05 FILLER PIC X(24)
VALUE '121110090807060504030201'.
05 FILLER PIC X(24)
VALUE '121110090807060504030201'.
01 DUH-MONTH-TAB
REDEFINES
DUH-MONTH-DEFINITION.
05 DUH-MONTH-ITEM OCCURS 24 TIMES.
PIC X(02).
|
find your MM in the DUH-MONTH-ITEM -
set DUH-FIRST-SUBSCRIPT to that occurance.
ADD 11 TO DUH-FIRST-SUBCRIPT GIVING DUH-LAST-SUBSCRIPT
now, your range is
current month - DUH-FIRST-SUBSCRIPT
thru
preceding - DUH-LAST-SUBSCRIPT |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
Fine as long as the current month is always 11 or 12, what happens when the range includes a year change? And that only gives you 11 months not the current + previous 11 months. |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
Correction that does give you a full 12 months but there is still the problem with the year. I guess some people have all ready forgotten the problems with 2 digit years. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
well, he did not say he wanted year,
but as soon as the month is larger than the last, then subtract 1 from the year. |
|
Back to top |
|
|
sskpen
New User
Joined: 30 Aug 2006 Posts: 14
|
|
|
|
Thanks for your quick response |
|
Back to top |
|
|
|