Many thanks to you Sri, excellent help as usual.  This is just what I needed.

Peter

-----Original Message-----
From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On Behalf 
Of Sri h Kolusu
Sent: Thursday, July 13, 2017 11:40 AM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: Re: Is there a SORT day-of-week function?

Peter,

DFSORT has an array of date related functions. To answer your question, yes we 
can find the day of the week and even the week number too. We can also get the 
NEXT or PREV day of the week based on a date.

Here is a simple example of getting the day of the week.

//STEP0100 EXEC PGM=SORT 
//SYSOUT   DD SYSOUT=* 
//SYMNAMES DD *
DAYOFWEEK,S'&LWDAY' 
//SORTIN   DD * 
PETER
//SORTOUT  DD SYSOUT=* 
//SYSIN    DD * 
  OPTION COPY
  INREC OVERLAY=(10:DAYOFWEEK)
//* 

The output will be 

PETER    THU

If you need to create the NEXT day of week date based on the day of the week of 
the current date then you can use the following

//STEP0100 EXEC PGM=SORT 
//SYSOUT   DD SYSOUT=* 
//SORTIN   DD * 
PETER
//SORTOUT  DD SYSOUT=* 
//SYSIN    DD * 
  OPTION COPY
  INREC IFOUTLEN=80, 
        IFTHEN=(WHEN=INIT, 
             OVERLAY=(10:DATE1, 
                      81:10,8,Y4T,WEEKDAY=CHAR3)), 
        IFTHEN=(WHEN=(81,3,SS,EQ,C'MON,TUE'), 
             OVERLAY=(20:10,8,Y4T,NEXTDFRI,TOGREG=Y4T)), 
        IFTHEN=(WHEN=(81,3,SS,EQ,C'WED,THU,FRI,SAT,SUN'), 
             OVERLAY=(20:10,8,Y4T,NEXTDMON,TOGREG=Y4T)) 
 
  OUTFIL REMOVECC,
  HEADER1=(10:'CURRDATE',20:'NEXTDATE',/, 
           10:'--------',20:'--------') 
                                                      
The output from this is 

         CURRDATE  NEXTDATE
         --------  --------
PETER    20170713  20170717



If you need to go back to previous days then also it is quite simple. 
Simply change the NEXTDday to PREVDday

NEXTDday can be used to calculate the next specified day for a date field. 
As a simple example, you could use the following to calculate the next Friday 
for a C'ccyyddd' date as a C'ccyy.ddd' date:

     3,7,Y4T,NEXTDFRI,TOJUL=Y4T(.)


PREVDday can be used to calculate the previous specified day for a date field. 
As a simple example, you could use the following to calculate the previous 
Wednesday for a P'yyddd' date as a  C'ccyymmdd' date:


         51,3,Y2U,PREVDWED,TOGREG=Y4T


Further if you have any questions please let me know

Thanks,
Kolusu
DFSORT Development
IBM Corporation



From:   "Farley, Peter x23353" <peter.far...@broadridge.com>
To:     IBM-MAIN@LISTSERV.UA.EDU
Date:   07/12/2017 02:38 PM
Subject:        Is there a SORT day-of-week function?
Sent by:        IBM Mainframe Discussion List <IBM-MAIN@LISTSERV.UA.EDU>



Is there any way in SORT control cards (either DFSORT or SYNCSORT) to test for 
a certain day of the week?  Something like this, assuming '3' 
represents the DOW value for Wednesday:

OUTREC IFTHEN=(WHEN=(DOW(&DATE1),EQ,3),
                                    BUILD=(C'WEDNESDAY=DATE VALUE + 
5',&DATE1+5)),
                 IFTHEN=(WHEN=(DOW(&DATE1),NE,3),
                                    BUILD=(C'NOT-WEDNESDAY=DATE VALUE +
3',&DATE1+3))

I have searched in both vendors' FM's but I did not find any indication of such 
a function.

I know I can handle such a requirement in an exit routine (and more flexibly as 
well), but I was hoping someone already needed such a function and one of the 
vendors already provided a solution, maybe with an SPE (documented or not).

TIA for any help you  can provide.

Peter

--

This message and any attachments are intended only for the use of the addressee 
and may contain information that is privileged and confidential. If the reader 
of the message is not the intended recipient or an authorized representative of 
the intended recipient, you are hereby notified that any dissemination of this 
communication is strictly prohibited. If you have received this communication 
in error, please notify us immediately by e-mail and delete the message and any 
attachments from your system.

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

Reply via email to