IBM MAINFRAME HELP & SUPPORT FORUMS
Technical Forums for IBM Mainframe Applications like COBOL, JCL, CICS, DB2, FileAid, DFSORT, Endevor, Xpediter, CoolGen, CA-7&11, AbendAid, IMS, IDMS, PL/I, MqSeries, SyncSort, Assembler, ChangeMan, Easytrieve, InterTest, REXX, CLIST etc...
 

Getting the all the dates between two range of dates

THIS IS AN ARCHIVE FORUM: CLICK HERE TO GO TO THE ORIGINAL TOPIC

 
       IBMMAINFRAMES.com - IBM Mainframe Support Forums Index -> CLIST & REXX
View previous topic :: View next topic  
Author Message
vidyaa



Joined: 02 May 2008
Posts: 36
Location: chennai

Posted: Wed Jul 09, 2008 11:17 am    Post subject: Getting the all the dates between two range of dates  

Hi,
i have an input file with the set of STARTDATE and ENDDATE
in two different columns. if the user inputs an STARTDATE and ENDDATE
i need to retrive all the records lying between the range specified by the user

EX: my input file is like and the dates are in MM/DD/YYYY format
NAME AGN STARTDATE ENDDATE
AAA,123,01/12/2007,08/12/2009
BBB,111,02/13/2006,02/12/2008
CCC,345,02/14/2008,03/15/2009
DDD,889,04/12/2008,05/12/2009

If the user gives the STARTDATE=01/12/2007 and ENDDATE=08/12/2009
then my output shoul have all the records existing in and between these dates hence my output will be like
AAA,123,01/12/2007,08/12/2009
CCC,345,02/14/2008,03/15/2009
DDD,889,04/12/2008,05/12/2009

how can this be made please let me know your suggestions.
Back to top  
enrico-sorichetti



Joined: 14 Mar 2007
Posts: 3082
Location: italy

Posted: Wed Jul 09, 2008 11:35 am    Post subject: Reply to: Getting the all the dates between two range of dat  

You can use a rough approach ( given that the dates are valid )

transform the date to the "S" format - YYYYMMDD - check the rexx docs
and then carry on a simple comparison


given that
lowr_date will contain the start date - "S" format
high_date will contain the end date - "S" format

get_rec is the procedure/function to read records - with the effect of setting the EOF indicator and filling the recd variable with the record
put_rec is the procedure/function to write record

Code: EOF = 0
call get_rec

do while ( EOF = 0 )
    /* parse the record to get the dates
    date1 = substr(recd,year1,4) || substr(recd,month1,2) || substr(recd,day1,2)
    date2 = substr(recd,year2,4) || substr(recd,month2,2) || substr(recd,day2,2)
    /* check the date limits
    if ( lowr_date <= date1 ) & ,
         ( high_dat >= date2 ) then ,
        call put_rec
    call get_rec
end





Back to top  
vidyaa



Joined: 02 May 2008
Posts: 36
Location: chennai

Posted: Wed Jul 09, 2008 2:57 pm    Post subject: Reply to: Getting the all the dates between two range of dat  

Thank you so much enrico-sorichetti

this works amazing.
Back to top  
 
       IBMMAINFRAMES.com - IBM Mainframe Support Forums Index -> CLIST & REXX
Page 1 of 1
THIS IS AN ARCIVE FORUM IN READ ONLY MODE. IF YOU WANT TO ASK YOUR DOUBTS USE THE ACTUAL FORUM