Page 1 of 2

How to subtract days from a date using days

PostPosted: Thu Jun 09, 2011 12:15 pm
by coollearner
I have the following dates in a file:
16011986
17011986
18011986
19011986
20011986

I want to subtract 1034 days from all these days. please let me know how to do this.

Re: How to subtract days from a date using days

PostPosted: Thu Jun 09, 2011 10:27 pm
by Frank Yaeger
What is the format of the date? Is it ddmmyyyy or something else (what)?

What is the RECFM and LRECL of the input file?

Re: How to subtract days from a date using days

PostPosted: Fri Jun 10, 2011 12:26 pm
by coollearner
Frank Yaeger wrote:What is the format of the date? Is it ddmmyyyy or something else (what)?

What is the RECFM and LRECL of the input file?



The format is ddmmyyyy
RECFM is FB
LRECL is 80

Re: How to subtract days from a date using days

PostPosted: Fri Jun 10, 2011 9:11 pm
by Frank Yaeger
You can use a DFSORT job like the following to do what you asked for:

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
16011986
17011986
18011986
19011986
20011986
//SORTOUT DD SYSOUT=*
//SYSIN DD *
  OPTION COPY
* Convert from ddmmyyyy to yyyymmdd
  INREC IFTHEN=(WHEN=INIT,BUILD=(5,4,3,2,1,2)),
* Get yyyymmdd - 1034 days
    IFTHEN=(WHEN=INIT,BUILD=(1,8,Y4T,SUBDAYS,+1034,TOGREG=Y4T)),
* Convert from yyyymmdd to ddmmyyyy
    IFTHEN=(WHEN=INIT,BUILD=(7,2,5,2,1,4,80:X))
/*


SORTOUT would have:

19031983   
20031983   
21031983   
22031983   
23031983   

Re: How to subtract days from a date using days

PostPosted: Thu Jan 19, 2012 12:27 pm
by jvinoth
hi frank can you please tell me what is the use of Y4T in the condition...I am new to mainframe so please explain me

Re: How to subtract days from a date using days

PostPosted: Thu Jan 19, 2012 8:20 pm
by NicC
If you look at Frank's signature or the sticky topics at the top of this section of the forum you would find the necessary references to enable you to find out these things on your own. Frank, being the kind soul that he is, may come back with the exact reference that you need. But... doing the reading yourself will lead you to the other wonders of DFSort. (Sorry - on holiday and waxing lyrical!)

Re: How to subtract days from a date using days

PostPosted: Thu Jan 19, 2012 8:36 pm
by Akatsukami
NicC wrote:(Sorry - on holiday and waxing lyrical!)

Well don't let the wax contaminate the groundwater! :mrgreen:

Re: How to subtract days from a date using days

PostPosted: Thu Jan 19, 2012 10:06 pm
by skolusu
jvinoth,

Check this link which explains DFSORT Data Formats

If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:

http://www.ibm.com/support/docview.wss? ... g3T7000080

Re: How to subtract days from a date using days

PostPosted: Thu Jan 19, 2012 11:48 pm
by Frank Yaeger
jvinoth,

For specific information on DFSORT functions that use the Y4x formats, you can also see these papers:

http://www.ibm.com/support/docview.wss? ... g3T7000174

http://www.ibm.com/support/docview.wss? ... g3T7000242

Re: How to subtract days from a date using days

PostPosted: Fri Jan 20, 2012 2:29 pm
by jvinoth
thank you so much..