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 

DFSort - possible to perform date arithmetic?

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


Joined: 30 Aug 2004
Posts: 19
Topics: 8

PostPosted: Thu Sep 02, 2004 4:27 pm    Post subject: DFSort - possible to perform date arithmetic? Reply with quote

Is it possible to do arithmetic or calculate date intervals on dates and date constants using DFSort?

I've found lots of stuff on comparing dates in the docs, but so far have not been able to locate anything on calculations using dates.

In particular, what I'm trying to do is to find the month previous to the current month.

Thanks for any suggestions.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Thu Sep 02, 2004 5:39 pm    Post subject: Reply with quote

Sterling Price,

DFSORT has the capability of performing arthimetic functions, but it cannot be used to calculate the differences between 2 dates, subtracting/adding 'n' days to current date etc..

You may find some examples here

http://www.mvsforums.com/helpboards/viewtopic.php?t=2432&highlight=add
http://www.mvsforums.com/helpboards/viewtopic.php?t=2212&highlight=add


Check this link for selecting records with date manipulations

http://www.mvsforums.com/helpboards/viewtopic.php?t=1459&highlight=date1

Quote:

In particular, what I'm trying to do is to find the month previous to the current month.


That is simple, All you need is subtract 1 from the month and remember to subtract 1 from the year when the current month is january

Post your requirement and we will see if we can find a solution for it

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Sterling Price
Beginner


Joined: 30 Aug 2004
Posts: 19
Topics: 8

PostPosted: Fri Sep 03, 2004 6:52 am    Post subject: Reply with quote

My end goal is to produce a report with a title containing the previous month and the year, in the form:

August , 2004 (if the job ran in September 2004)

or

December, 2004 (if the job ran in January 2005)
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Mon Sep 06, 2004 7:46 am    Post subject: Reply with quote

Sterling price,

The following JCL will give you the desired results. we use the DATE1 parm to get the current date in the format(YYYYMMDD). Since you want the month name of the last month , we use a change command to spell out the name of the last month. We also split the file into 2 files, when the month is 01 , we write it out to HDR1 file, else we write it out to HDR2 file.

When the month is 01, then we need to subtract 1 from the year to get the previous year. so at any point we will only create one header.Either HDR1 or HDR2 file.

Code:

//STEP0100 EXEC PGM=SORT           
//SYSOUT   DD SYSOUT=*             
//SORTIN   DD *                   
DUMMY RECORD                       
//HDR1     DD SYSOUT=*             
//HDR2     DD SYSOUT=*             
//SYSIN    DD *                                         
  SORT FIELDS=COPY                                       
  INREC FIELDS=(DATE1,80:X)                             
  OUTREC FIELDS=(01,10,                                 
                 X,                                     
                 12:5,2,CHANGE=(10,C'01',C'DECEMBER, ', 
                                   C'02',C'JANUARY,  ', 
                                   C'03',C'FEBRUARY, ', 
                                   C'04',C'MARCH,    ', 
                                   C'05',C'APRIL,    ', 
                                   C'06',C'MAY,      ', 
                                   C'07',C'JUNE,     ', 
                                   C'08',C'JULY,     ', 
                                   C'09',C'AUGUST,   ', 
                                   C'10',C'SEPTEMBER,', 
                                   C'11',C'OCTOBER,  ', 
                                   C'12',C'NOVEMBER, '),
                 80:X)                                   
  OUTFIL FNAMES=HDR1,INCLUDE=(5,2,CH,EQ,C'01'),
   OUTREC=(12,10,                               
          +1,SUB,1,4,ZD,EDIT=(TTTT),80:X)       
  OUTFIL FNAMES=HDR2,SAVE,                     
   OUTREC=(12,10,X,1,4,80:X)                     
/*


Hope this helps...

Cheers

kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Sterling Price
Beginner


Joined: 30 Aug 2004
Posts: 19
Topics: 8

PostPosted: Tue Sep 14, 2004 6:12 am    Post subject: Reply with quote

It worked perfectly. Thank you very much.
Back to top
View user's profile Send private message
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