Page 1 of 1

Date Formatting.

PostPosted: Fri Jul 30, 2010 7:47 pm
by Vineet
Hi All,

I am having a query Related To SORT. I am having a Sequential File having 2 Date Fields say date1 & date2. My Requirement is. I need to Select all records from the File where Date1 >= Current Date (System date) & Date2 <= Current Date + 48 Days. Date1 & Date2 having Format as : YYYY-MM-DD.

Do we Need To Reformat Date To Format = YYYYMMDD or Required Result Can be Achived using Format: YYYY-MM-DD.


Thanks
Kind Rgds

Re: Date Formatting.

PostPosted: Fri Jul 30, 2010 8:36 pm
by Frank Yaeger
If you use DFSORT's UFF format, it will extract YYYYMMDD from YYYY-MM-DD so you wouldn't need to reformat the date.

Re: Date Formatting.

PostPosted: Fri Jul 30, 2010 8:39 pm
by Vineet
Thanks frank. I appreciate if U can provide me sort card. Also as per My Requirement i need to retrieve Records In The rage of Current Date AND Current Date + 48 Days.

Re: Date Formatting.

PostPosted: Fri Jul 30, 2010 9:24 pm
by skolusu
vineet,

The following DFSORT JCL will give you the desired results. I assumed your date1 in file is at pos 1 and date 2 is at pos 15.

//STEP0100 EXEC PGM=SORT                                     
//SYSOUT   DD SYSOUT=*                                       
//SORTIN   DD *                                             
2010-07-29    2010-09-15     DROP                           
2010-07-30    2010-09-16     PICK                           
2010-07-31    2010-09-17     DROP                           
//SORTOUT  DD SYSOUT=*                                       
//SYSIN    DD *                                             
  SORT FIELDS=COPY                                           
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:DATE1(-),DATE1(-)+48))
  OUTFIL BUILD=(1,80),                                       
  INCLUDE=(1,10,CH,GE,81,10,CH,AND,15,10,CH,LE,91,10,CH)     
//*

Re: Date Formatting.

PostPosted: Fri Jul 30, 2010 9:34 pm
by Vineet
Hi SKOLUSU,
Thanks for the Reply. to be More Precise. date1 Starts from col. 93 & Date2 Starts from Col. 104. Length Of Output File is = 1330. Please tell In Overlay U stated '81:' what does this Mean. I really Appreciate U helped me out.
Thanks
Kind Rgds

Vineet Anand

Re: Date Formatting.

PostPosted: Fri Jul 30, 2010 10:10 pm
by skolusu
Vineet,

The logic is quite simple. The first inrec statement writes 2 date values at pos 1331 which is at the end of the record.

Date1 is current date in CCYYMMDD format , since your input dates are CCYY-MM-DD we use Date1(-) format.

We populate current date and current date + 48 days at the end of every record.

Using an INCLUDE on OUTFIL we validate the dates and while writing out we remove the extra fields we created at the end using BUILD statement

//STEP0100 EXEC PGM=SORT                                     
//SYSOUT   DD SYSOUT=*                                       
//SORTIN   DD DSN=Your input FB 1330 byte file,DISP=SHR
//SORTOUT  DD DSN=your output Fb 1330 byte file,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(CYL,(X,Y),RLSE)
//SYSIN    DD *                                             
  SORT FIELDS=COPY                                           
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(1331:DATE1(-),DATE1(-)+48))

  OUTFIL BUILD=(1,1330),                                       
  INCLUDE=(93,10,CH,GE,1331,10,CH,AND,104,10,CH,LE,1341,10,CH)     
//*

Re: Date Formatting.

PostPosted: Sat Jul 31, 2010 7:43 am
by Vineet
Hi SKOLUSU,

Thanks a Zillion for UR Help. It worked For Me. I Really Appreciate UR Effort & Precious Time U Spent in Helping me out. Can U Provide me Any Site From where I can Download Stuff Related to SORT Or Any Study Material which I can refer, This will be of Great help to me.

Thanks Once Again.

Kind Rgds
Vineet Anand

Re: Date Formatting.

PostPosted: Mon Aug 02, 2010 9:38 pm
by skolusu
Vineet wrote:Hi SKOLUSU,

Thanks a Zillion for UR Help. It worked For Me. I Really Appreciate UR Effort & Precious Time U Spent in Helping me out. Can U Provide me Any Site From where I can Download Stuff Related to SORT Or Any Study Material which I can refer, This will be of Great help to me.

Thanks Once Again.

Kind Rgds
Vineet Anand



Vineet,

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/servers/storage/supp ... tmpub.html