Page 1 of 1

MIN and MAX Date

PostPosted: Wed Jan 09, 2013 10:23 am
by Fly Simply
Hi Everyone,

I have a dataset in which the dates are in PD format (Col 19). What I am trying to achieve is. I want to get the MIN and MAX Date from huge dataset. I created a JCL with which I was able to achieve this.

//**********************************************************************
//*GET MAX AND MIN FOR DATE         
//**********************************************************************
//STEP1    EXEC PGM=SORT,REGION=0M                                     
//SORTIN   DD   DISP=SHR,DSN=TEST.INPUT                 
//SORTOUT  DD   SYSOUT=*                                               
//SYSPRINT DD SYSOUT=*                                                 
//SYSOUT   DD SYSOUT=*                                                 
//SYSIN DD *                                                           
  SORT FIELDS=(19,4,CH,A)                                               
  OUTFIL NODETAIL,REMOVECC,                                             
      TRAILER2=('DATE: ',                       
        MIN=(19,4,PD,TO=ZD),' - ',MAX=(19,4,PD,TO=ZD))                 


The output of this JCL is in Format:
DATE: 2012044 - 2012296
Date Format: CCYYDDD (Julian Date)

I have been looking over various forums but could not find a way to convert this julian date to Gregorian Date Format (MM/DD/CCYYY)
Is there a way to further tweak parameters of MIN/MAX to reformat the dates. I know another way to convert the date, but I am not sure how they can be integrated in one.

INREC BUILD=(19,4,Y4T,TOGREG=Y2T)


Please pour in your suggestions and point out, if my approach is incorrect.

Thanks. :)

Re: MIN and MAX Date

PostPosted: Wed Jan 09, 2013 1:04 pm
by enrico-sorichetti
see here
ftp://ftp.software.ibm.com/storage/dfso ... rttrck.pdf

IIRC the right format should be something like
Y2U,TOGREG=Y4W(/)

Re: MIN and MAX Date

PostPosted: Wed Jan 09, 2013 10:53 pm
by Fly Simply
Enrico, Thanks for your response. But can the parameters mentioned above be used with MAX/MIN functions ?

Re: MIN and MAX Date

PostPosted: Wed Jan 09, 2013 11:39 pm
by skolusu
Fly Simply wrote:Enrico, Thanks for your response. But can the parameters mentioned above be used with MAX/MIN functions ?


Fly simply,

Date conversion functions are not available with Reporting features. Use the following DFSORT JCL which will give you the desired results. Based on offline discussion about RECFM and other details.
//STEP0100 EXEC PGM=SORT                                       
//SYSOUT   DD SYSOUT=*                                         
//SORTIN   DD DISP=SHR,DSN=Your input VB file
//SORTOUT  DD DSN=&&FB,DISP=(,PASS),SPACE=(TRK,(1,0),RLSE)     
//SYSIN    DD *                                               
  OPTION COPY                                                 
  INREC BUILD=(1,4,19,4)                                       
  OUTFIL VTOF,REMOVECC,NODETAIL,BUILD=(80X),                   
  TRAILER1=('DATE: ',MIN=(5,4,PD,M11,LENGTH=7),4X,'- ',       
                     MAX=(5,4,PD,M11,LENGTH=7))               
//*                                                           
//STEP0200 EXEC PGM=SORT                                       
//SYSOUT   DD SYSOUT=*                                         
//SORTIN   DD DSN=&&FB,DISP=SHR                               
//SORTOUT  DD SYSOUT=*                                         
//SYSIN    DD *                                               
  OPTION COPY                                                 
  INREC OVERLAY=(7:7,7,Y4T,DT=(MD4/),20:20,7,Y4T,DT=(MD4/))   
//*