Date Formatting.



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

Date Formatting.

Postby Vineet » Fri Jul 30, 2010 7:47 pm

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
Vineet
 
Posts: 86
Joined: Tue Jun 19, 2007 11:38 am
Has thanked: 0 time
Been thanked: 0 time

Re: Date Formatting.

 

Re: Date Formatting.

Postby Frank Yaeger » Fri Jul 30, 2010 8:36 pm

If you use DFSORT's UFF format, it will extract YYYYMMDD from YYYY-MM-DD so you wouldn't need to reformat the date.
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
User avatar
Frank Yaeger
Global moderator
 
Posts: 1080
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 14 times

Re: Date Formatting.

Postby Vineet » Fri Jul 30, 2010 8:39 pm

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.
Vineet
 
Posts: 86
Joined: Tue Jun 19, 2007 11:38 am
Has thanked: 0 time
Been thanked: 0 time

Re: Date Formatting.

Postby skolusu » Fri Jul 30, 2010 9:24 pm

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)     
//*
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

Re: Date Formatting.

Postby Vineet » Fri Jul 30, 2010 9:34 pm

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
Vineet
 
Posts: 86
Joined: Tue Jun 19, 2007 11:38 am
Has thanked: 0 time
Been thanked: 0 time

Re: Date Formatting.

Postby skolusu » Fri Jul 30, 2010 10:10 pm

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)     
//*
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

Re: Date Formatting.

Postby Vineet » Sat Jul 31, 2010 7:43 am

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
 
Posts: 86
Joined: Tue Jun 19, 2007 11:38 am
Has thanked: 0 time
Been thanked: 0 time

Re: Date Formatting.

Postby skolusu » Mon Aug 02, 2010 9:38 pm

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
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