subtract 1 day to a date



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

subtract 1 day to a date

Postby javivi » Tue Jan 25, 2011 5:33 pm

Hi
I can't use the last SUBDAYS function in dfsort because the PTF is not availabe in my installation.
I need to subtract 1 day to a date in a sortin file but I can't do it. I'm trying the next, but the result are wrong.

//SORTIN DD *
20100507
//SORTOUT DD DSN=THEOUT.FILE,DISP=(,CATLG,CATLG),
// DCB=(RECFM=FB,LRECL=25,BLKSIZE=0),
// UNIT=SYSDA,SPACE=(TRK,(1,1),RLSE)
//SYSOUT DD SYSOUT=*
//SYSIN DD *
OPTION DYNALLOC=(,12)
SORT FIELDS=COPY
INREC OVERLAY=(40:01,08,Y4T,TOJUL=Y4T)
OUTREC OVERLAY=(50:40,07,ZD,SUB,+1)
OUTFIL BUILD=(01,08,C'*',40,07,C'*',50,7,Y4T,TOGREG=Y4T)
END

This is the result:

20100507*2010127*

Someone can help me?

Thanks.
javivi
 
Posts: 47
Joined: Fri Jan 21, 2011 2:53 pm
Has thanked: 0 time
Been thanked: 0 time

Re: subtract 1 day to a date

 

Re: subtract 1 day to a date

Postby skolusu » Tue Jan 25, 2011 10:56 pm

Javivi,

You are performing arithmetic on the entire 7 bytes of Julian date which is not correct. You need to perform arithmetic just on DDD portion of the julian date. You also need to take care of January 1st. If the input date is January 1st , you need to subtract 1 from the year. Here is a DFSORT JCL which will give you the desired results

//STEP0100 EXEC PGM=SORT                                 
//SYSOUT   DD SYSOUT=*                                   
//SORTIN   DD *                                           
20100507                                                 
//SORTOUT  DD SYSOUT=*                                   
//SYSIN    DD *                                           
  SORT FIELDS=COPY                                       
  INREC IFOUTLEN=25,                                     
  IFTHEN=(WHEN=INIT,OVERLAY=(09:C'*',1,8,Y4T,TOJUL=Y4T,   
          26:10,4,14,3,ZD,SUB,+1,M11,LENGTH=3)),         
  IFTHEN=(WHEN=(30,3,ZD,EQ,0),                           
  OVERLAY=(17:C'*',26,4,ZD,SUB,+1,M11,LENGTH=4,C'1231')),
  IFTHEN=(WHEN=(30,3,ZD,GT,0),                           
  OVERLAY=(17:C'*',26,7,Y4T,TOGREG=Y4T))                 
/*


This will produce the following output

20100507*2010127*20100506
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
skolusu
 
Posts: 586
Joined: Wed Apr 02, 2008 10:38 pm
Has thanked: 0 time
Been thanked: 39 times


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post