MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

need to select records based on date range

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
yadav2005
Intermediate


Joined: 10 Jan 2005
Posts: 348
Topics: 144

PostPosted: Wed Dec 03, 2008 1:55 pm    Post subject: need to select records based on date range Reply with quote

Members,

I have file in which there are many records and each record has a field which has a date entry in the format of MM/DD/YY.Now the dates could be from 01/01/08 till date 12/04/08.Is there a way to filter out only records which are in the range from 01/01/08 - 07/31/08 , somewhat like between these dates only i want to select the records.Is there any function in DFSORT where we can achieve the result.I do not want to put in the INLCUDE CONDITION checking for each day from Jan 01 - Jul 31.

We can also have a leap year and record for February 29 th could also occur 02/29/08 and sometimes it could also not be a leap year , how can we do this task.
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Wed Dec 03, 2008 2:18 pm    Post subject: Reply with quote

You can use a DFSORT job like the following to do what you asked for. I assumed your date starts in position 1 and your input file has RECFM=FB and LRECL=80, but you can change the job as needed.

Code:

//S1    EXEC  PGM=ICEMAN                                             
//SYSOUT    DD  SYSOUT=*                                             
//SORTIN DD *                                                         
12/31/07  NO                                                         
01/01/08  YES                                                         
01/02/08  YES                                                         
02/29/08  YES                                                         
07/31/08  YES                                                         
08/01/08  NO                                                         
12/04/08  NO                                                         
//SORTOUT DD SYSOUT=*                                                 
//SYSIN    DD    *                                                   
  OPTION COPY,Y2PAST=1980                                             
  INREC OVERLAY=(81:1,8,UFF,M11,LENGTH=6)                             
  OUTFIL INCLUDE=(81,6,Y2W,GE,Y'080101',AND,81,6,Y2W,LE,Y'080731'),   
    BUILD=(1,80)                                                     


SORTOUT would have:

Code:

01/01/08  YES   
01/02/08  YES   
02/29/08  YES   
07/31/08  YES   

_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
yadav2005
Intermediate


Joined: 10 Jan 2005
Posts: 348
Topics: 144

PostPosted: Wed Dec 03, 2008 2:29 pm    Post subject: Reply with quote

Frank,

Thanks a lot for such a quick reply.Can you help me in understanding why you have used Y2PAST=1980, what does UFF mean and you have used mask M11 with length as 6 ,i guess u are making to MMDDYY format with 6 bytes and what is Y2W.
Back to top
View user's profile Send private message
yadav2005
Intermediate


Joined: 10 Jan 2005
Posts: 348
Topics: 144

PostPosted: Wed Dec 03, 2008 3:19 pm    Post subject: Reply with quote

Frank,

How should i tailor my code if my date starts at position 100 , can you please help me modifying the code.
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Wed Dec 03, 2008 3:27 pm    Post subject: Reply with quote

Y2PAST=1980 sets the century window from 1980-2079. So two-digit years from 80 to 99 are treated as 19yy years and two-digit years from 00-79 are treated as 20yy years. If that's not appropropriate, change it (e.g. Y2PAST=2000 would give a century window from 2000-2099).

UFF,M11,LENGTH=6 uses DFSORT's unsigned free form format (UFF) to extract the digits from your mm/dd/yy values resulting in 'mmddyy' values (e.g. 12/31/07 -> 123107).

Y2W is a DFSORT format that uses the century window to operate on an 'mmddyy' date. Y'yymmdd' is a yymmdd constant that uses the century window. Using Y2W with a Y'yymmdd' constant allows you to compare an 'mmddyy' date in a record to a 'yymmdd' constant - it handles normalizing the dates to the same form.
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
yadav2005
Intermediate


Joined: 10 Jan 2005
Posts: 348
Topics: 144

PostPosted: Wed Dec 03, 2008 3:38 pm    Post subject: Reply with quote

Frank thanks for the explanation it is clear to me now , can you help me modifying the code if my date starts from column 100.Thanks.
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Wed Dec 03, 2008 4:05 pm    Post subject: Reply with quote

What is the RECFM and LRECL of the input file?
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
yadav2005
Intermediate


Joined: 10 Jan 2005
Posts: 348
Topics: 144

PostPosted: Wed Dec 03, 2008 8:19 pm    Post subject: Reply with quote

Frank,

The RECFM is VB and LRECL = 151 and the date field starts at pos 100.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed Dec 03, 2008 11:21 pm    Post subject: Reply with quote

yadav2005,

Since it is a VB file, I am assuming that you already have counted the RDW in determining the position of the date field. So try these control cards

Code:

//SYSIN    DD *                                                   
  OPTION COPY,Y2PAST=1980                                         
  INREC BUILD=(1,4,5:100,8,UFF,M11,LENGTH=6,5)                   
  OUTFIL INCLUDE=(5,6,Y2W,GE,Y'080101',AND,5,6,Y2W,LE,Y'080731'),
      BUILD=(1,4,11)                                             
//*



Hope this helps...

Cheers
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group