Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Sort a date field which is in the format CCYY/MM/DD

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
View previous topic :: :: View next topic  
Author Message
murugan_mf

Active User


Joined: 31 Jan 2008
Posts: 148
Location: Chennai, India

PostPosted: Fri Apr 03, 2009 6:30 pm    Post subject: Sort a date field which is in the format CCYY/MM/DD
Reply with quote

Hi,

My requirement is to sort a file based on date. The input file contains
date in the format ccyy/mm/dd (eg 2009/04/03).

In sort control card i used the following
The date field starts from position 5 in my input file.
Code:
sort fields=(5,10,date)


Is there anything to be added to specify the date format.

Insert Current Date using Syncsort
Back to top
View user's profile Send private message

murugan_mf

Active User


Joined: 31 Jan 2008
Posts: 148
Location: Chennai, India

PostPosted: Mon Apr 06, 2009 2:50 pm    Post subject:
Reply with quote

I have mentioned the format incorrectly.
It should be mm/dd/yyyy.
Back to top
View user's profile Send private message
subinraj

New User


Joined: 04 Sep 2007
Posts: 16
Location: Bangalore

PostPosted: Mon Apr 06, 2009 3:58 pm    Post subject:
Reply with quote

If your input is in the following format

Code:
XXXX04/03/2009
XXXX04/03/2008
XXXX01/12/2009
XXXX03/11/2009
XXXX04/06/2009
XXXX04/06/2006
XXXX02/25/2009


The sort card should be

Code:
SORT FIELDS=(11,4,CH,A,             * CCYY
             05,2,CH,A,             * MM   
             08,2,CH,A)             * DD   
Back to top
View user's profile Send private message
murugan_mf

Active User


Joined: 31 Jan 2008
Posts: 148
Location: Chennai, India

PostPosted: Mon Apr 06, 2009 5:42 pm    Post subject:
Reply with quote

Subinraj,

Thanks for your answer. I know it is possible by splitting a date into
month, day and year and sorting them.

I m interested to know, is there a way to sort by keeping it as a whole date (mm/dd/ccyy) instead of splitting them separately as month,day & year and sorting them.
Back to top
View user's profile Send private message
Alissa Margulies

SYNCSORT Support


Joined: 25 Jul 2007
Posts: 500
Location: USA

PostPosted: Mon Apr 06, 2009 8:54 pm    Post subject:
Reply with quote

murugan_mf wrote:
I m interested to know, is there a way to sort by keeping it as a whole date (mm/dd/ccyy) instead of splitting them separately as month,day & year and sorting them.

No, the only way that may work is if your data were as you originally specified (ccyy/mm/dd). Since this is not how your data is formatted, you will need to sort on the fields separately, as subinraj described.

Your alternative would be to use INREC to reformat the data, sort the data, and then use OUTREC to reformat it back.
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Mon Apr 06, 2009 9:11 pm    Post subject:
Reply with quote

murugan_mf wrote:
Subinraj,

Thanks for your answer. I know it is possible by splitting a date into
month, day and year and sorting them.

I m interested to know, is there a way to sort by keeping it as a whole date (mm/dd/ccyy) instead of splitting them separately as month,day & year and sorting them.

I would think that keeping the 3 fields split as indicated would make the parameters more readable and understandable by whoever maintains that JCL in the future.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts SORT to unpack a feild shr_amar DFSORT/ICETOOL 7 Fri Jul 07, 2017 4:32 am
No new posts How to add header with Date(YYMMDD) i... Rajan Moorthy DFSORT/ICETOOL 2 Thu Jul 06, 2017 11:44 pm
No new posts How to write Specific Fields from Mul... Padhu SYNCSORT 6 Thu Jul 06, 2017 10:26 am
No new posts Optimize sort inrec parse vishwakotin DFSORT/ICETOOL 6 Mon Jun 26, 2017 11:15 pm
No new posts Reduce CPU Times for Join Sort santoshn SYNCSORT 12 Sat Jun 10, 2017 1:40 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us