Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Getting the all the dates between two range of dates

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
vidyaa

New User


Joined: 02 May 2008
Posts: 72
Location: chennai

PostPosted: Wed Jul 09, 2008 11:17 am    Post subject: Getting the all the dates between two range of dates
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10277
Location: italy

PostPosted: Wed Jul 09, 2008 11:35 am    Post subject: Reply to: Getting the all the dates between two range of dat
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: 72
Location: chennai

PostPosted: Wed Jul 09, 2008 2:57 pm    Post subject: Reply to: Getting the all the dates between two range of dat
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    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts outrec field outside range Danielle.Filteau SYNCSORT 10 Sat Mar 04, 2017 2:37 am
No new posts To determine the range on a Alphanume... Prasanth Kumar COBOL Programming 3 Mon Feb 15, 2016 9:35 am
No new posts Sort Card : To get the records with ... pecsakthivel123 DFSORT/ICETOOL 7 Thu Dec 10, 2015 11:54 pm
No new posts Expand a numeric range Donnov DFSORT/ICETOOL 5 Fri Sep 18, 2015 6:27 pm
No new posts difference between dates in months C... josepnass Testing & Performance analysis 6 Wed Jun 18, 2014 2:30 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us