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

Subtract birthdate in input file from current date !


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
techslam

New User


Joined: 03 Dec 2010
Posts: 87
Location: India

PostPosted: Thu Aug 02, 2012 4:39 pm
Reply with quote

Hello,
My Input file has date of births [LRECL=80]
Code:
 
RECORD1 1985-09-10
RECORD2 1975-09-10
RECORD3 1965-09-10
RECORD4 1955-09-10
RECORD5 1945-09-10
 


I need to subtract the birthdate in file from CURRENT DATE and check if the Difference is greater than value 00179999, and write only those record for which this condition is true. Can this be done using DATEDIFF funtion of DFSORT ?


Please guide me. Thanks
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Aug 02, 2012 4:43 pm
Reply with quote

i almost bothered to look it up for you
(the link that SKOLUSU provided,
www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000242
in the other thread that you originally posted this question,
and in the new thread that Bill created,
well, my post count is up, anyway!),
but then I divided 00179999 by 365 and that was about 494 years
so you did not mean days, apparently.

WTH does 00179999 represent?
Back to top
View user's profile Send private message
techslam

New User


Joined: 03 Dec 2010
Posts: 87
Location: India

PostPosted: Thu Aug 02, 2012 4:44 pm
Reply with quote

@dbzTHEdinosauer


DATEDIFF function does give us the difference in number of days, so this difference has to be greater than 00179999 , only then that particular record can be written to output file
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Aug 02, 2012 4:48 pm
Reply with quote

FM,

00179999 days divided by 365 is approx 494 years.

current date 2012 - 494 years = approx 1518.
got any birthdates in that area on file?????
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Thu Aug 02, 2012 4:49 pm
Reply with quote

techslam, you recognize that the only birth dates qualifying would be in the Julian calendar, a/k/a "Old Style", yes?
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Aug 02, 2012 4:50 pm
Reply with quote

Akatsukami wrote:
techslam, you recognize that the only birth dates qualifying would be in the Julian calendar, a/k/a "Old Style", yes?


good point, completely forgot about that,
may have to revise my question..
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Thu Aug 02, 2012 4:56 pm
Reply with quote

dbzTHEdinosauer wrote:
Akatsukami wrote:
techslam, you recognize that the only birth dates qualifying would be in the Julian calendar, a/k/a "Old Style", yes?


good point, completely forgot about that,
may have to revise my question..

IIRC, the current difference between the Julian and Gregorian calendars is only 14 days, not nearly enough to make whatever techslam is trying to do reasonable.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Thu Aug 02, 2012 5:00 pm
Reply with quote

the TS has THREE topics on the same rubbish,
unless he comes up quickly with a clear description of the requirement
and a clear indication of where he wants the discussion continued
all the topics will be locked and deleted after a while icon_cool.gif
Back to top
View user's profile Send private message
techslam

New User


Joined: 03 Dec 2010
Posts: 87
Location: India

PostPosted: Thu Aug 02, 2012 5:14 pm
Reply with quote

I Apologies for this duplicate topics.

Let the dicussion continue here and other two topics can be locked
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Aug 02, 2012 5:33 pm
Reply with quote

we are waiting on you
Aslam
to provide an reasonable requirement.

as of yet, you have not.
Back to top
View user's profile Send private message
techslam

New User


Joined: 03 Dec 2010
Posts: 87
Location: India

PostPosted: Thu Aug 02, 2012 5:41 pm
Reply with quote

Hi All,

I have kind of implemented this rquirement using ICETOOL. The code is below :-

Code:

//S1 EXEC PGM=ICETOOL                                           
//TOOLMSG DD SYSOUT=*                                           
//DFSMSG DD SYSOUT=*                                           
//IN DD *                                                       
13000601 RECORD1                                               
19820401 RECORD2                                               
19750201 RECORD3                                               
19790501 RECORD4                                               
19730701 RECORD5                                               
19800501 RECORD6                                               
19870101 RECORD7                                               
19600801 RECORD8                                               
//OUT1 DD DSN=TEST.ASLAM.ME.OUT1,DISP=(NEW,CATLG,DELETE)     
//OUT2 DD DSN=TEST.ASLAM.ME.OUT2,DISP=(NEW,CATLG,DELETE)     
//OUT3 DD DSN=TESTN.ASLAM.ME.OUT3,DISP=(NEW,CATLG,DELETE)     
//TOOLIN DD *                                                   
 COPY FROM(IN)     TO(OUT1) USING(CTL1)                             
 COPY FROM(OUT1) TO(OUT2) USING(CTL2)                           
 COPY FROM(OUT2) TO(OUT3) USING(CTL3)                           
/*                                                             
//CTL1CNTL DD *                                                 
 SORT FIELDS=COPY                                               
 OUTREC OVERLAY(50:DATE1)                                       
/*                                                             
//CTL2CNTL DD *                                                 
 SORT FIELDS=COPY                                               
 INREC OVERLAY(50:50,8,Y4T,DATEDIFF,1,8,Y4T)                   
/*                                                             
//CTL3CNTL DD *                                                 
 SORT FIELDS=COPY                                               
 INCLUDE COND=(51,7,ZD,GT,00179999)                             
/*             


The DOB in first record is a dummy date 13000601, just to make sure there is some output based on the final condition.

I know the above code can be written in a far better way.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Aug 02, 2012 5:49 pm
Reply with quote

Use SORT not ICETOOL
put DATE1 in SYSNAMES
in INREC do your overlay (use the SYSNAMES name)
in OUTREC do you INCLUDE

one output file.
Back to top
View user's profile Send private message
techslam

New User


Joined: 03 Dec 2010
Posts: 87
Location: India

PostPosted: Thu Aug 02, 2012 6:04 pm
Reply with quote

I tried below code -->

Code:

//S1 EXEC PGM=SORT                                               
//SYSOUT DD SYSOUT=*                                             
//SYSNAMES DD *                                                   
TDATE,DATE1                                                       
//SORTIN DD *                                                         
13000601 RECORD1                                                 
19820401 RECORD2                                                 
19750201 RECORD3                                                 
19790501 RECORD4                                                 
19730701 RECORD5                                                 
19800501 RECORD6                                                 
19870101 RECORD7                                                 
19600801 RECORD8                                                 
//SORTOUT DD DSN=TESTAEN.ASLAM.ME.OUT1,DISP=(NEW,CATLG,DELETE)       
//SYSIN DD *                                                     
  SORT FIELDS=COPY                                               
  INREC OVERLAY(50:TDATE,Y4T,DATEDIFF,1,8,Y4T)                   
  INCLUDE COND=(51,7,ZD,GT,00179999)                             
/*                             


Giving below error -->

Code:

ICE000I 1 - CONTROL STATEMENTS FOR 5694-A01, Z/OS DFSORT V1R12 -
            SORT FIELDS=COPY                                   
            INREC OVERLAY(50:TDATE,Y4T,DATEDIFF,1,8,Y4T)       
                             $                                 
ICE006A 0 OPERAND DEFINER ERROR                                 
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Aug 02, 2012 6:11 pm
Reply with quote

SYMNAMES not SYSNAMES
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Aug 02, 2012 6:14 pm
Reply with quote

Bill Woodger wrote:
SYMNAMES not SYSNAMES


my fault, I should have looked it up.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Aug 02, 2012 7:12 pm
Reply with quote

Hello,

Quote:
check if the Difference is greater than value 00179999
I suspect there is a misunderstanding in the number of days difference . . .

This may be supposed to select people over 18 years old (but 179999 is NOT the number of days. . .).

Possibly there will be a bit of clarification posted.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Thu Aug 02, 2012 9:49 pm
Reply with quote

techslam,

You don't need 3 passes of data to get the desired results. Here is a DFSORT JCL which will give you the desired results.
Code:

//STEP0100 EXEC PGM=SORT                               
//SYSOUT   DD SYSOUT=*                                 
//SORTIN   DD *                                       
13000601 RECORD1                                       
19820401 RECORD2                                       
19750201 RECORD3                                       
19790501 RECORD4                                       
19730701 RECORD5                                       
19800501 RECORD6                                       
19870101 RECORD7                                       
19600801 RECORD8                                       
//SORTOUT DD SYSOUT=*                                 
//SYSIN   DD *                                         
  OPTION COPY                                         
  INREC OVERLAY(81:DATE1,X,81,8,Y4T,DATEDIFF,1,8,Y4T) 
  OUTFIL BUILD=(1,80),INCLUDE=(90,8,SFF,GT,179999)     
//*


The output from this is
Code:

13000601 RECORD1


If your intention is to pick 18 years and older then you don't need Datediff function you can just subtract 18 years from the current date and use that date to compare your input dates.

Code:

//STEP0200 EXEC PGM=SORT                                   
//SYSOUT   DD SYSOUT=*                                     
//SORTIN   DD *                                             
20010601 RECORD1                                           
19820401 RECORD2                                           
19750201 RECORD3                                           
19790501 RECORD4                                           
19730701 RECORD5                                           
19800501 RECORD6                                           
19870101 RECORD7                                           
19600801 RECORD8                                           
//SORTOUT DD SYSOUT=*                                       
//SYSIN   DD *                                             
  OPTION COPY                                               
  INREC OVERLAY(81:DATE1,X,81,8,Y4T,SUBYEARS,+18,TOGREG=Y4T)
  OUTFIL BUILD=(1,80),INCLUDE=(1,8,ZD,LT,90,8,ZD)           
//*


The output from this job is
Code:

19820401 RECORD2 
19750201 RECORD3 
19790501 RECORD4 
19730701 RECORD5 
19800501 RECORD6 
19870101 RECORD7 
19600801 RECORD8 
Back to top
View user's profile Send private message
techslam

New User


Joined: 03 Dec 2010
Posts: 87
Location: India

PostPosted: Mon Aug 06, 2012 3:25 pm
Reply with quote

Thanks Skolusu and everyone.
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 -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts TRIM everything from input, output co... DFSORT/ICETOOL 1
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
Search our Forums:

Back to Top