IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

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


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
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
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
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
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
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: 496
Location: USA

PostPosted: Mon Apr 06, 2009 8:54 pm
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Populate last day of the Month in MMD... SYNCSORT 2
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
Search our Forums:

Back to Top