IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Getting the all the dates between two range of dates


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
vidyaa

New User


Joined: 02 May 2008
Posts: 77
Location: chennai

PostPosted: Wed Jul 09, 2008 11:17 am
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Wed Jul 09, 2008 11:35 am
Reply with quote

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
View user's profile Send private message
vidyaa

New User


Joined: 02 May 2008
Posts: 77
Location: chennai

PostPosted: Wed Jul 09, 2008 2:57 pm
Reply with quote

Thank you so much enrico-sorichetti

this works amazing.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts To get the count of rows for every 1 ... DB2 3
No new posts Generate random number from range of ... COBOL Programming 3
No new posts Amount of days between two dates PL/I & Assembler 8
No new posts Finding faulty logic Subscript out of... COBOL Programming 5
No new posts Particular data lies between a range ... DFSORT/ICETOOL 6
Search our Forums:

Back to Top