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.
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