View previous topic :: View next topic
|
Author |
Message |
murugan_mf
Active User
Joined: 31 Jan 2008 Posts: 148 Location: Chennai, India
|
|
|
|
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 |
|
|
murugan_mf
Active User
Joined: 31 Jan 2008 Posts: 148 Location: Chennai, India
|
|
|
|
I have mentioned the format incorrectly.
It should be mm/dd/yyyy. |
|
Back to top |
|
|
subinraj
New User
Joined: 04 Sep 2007 Posts: 16 Location: Bangalore
|
|
|
|
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 |
|
|
murugan_mf
Active User
Joined: 31 Jan 2008 Posts: 148 Location: Chennai, India
|
|
|
|
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 |
|
|
Alissa Margulies
SYNCSORT Support
Joined: 25 Jul 2007 Posts: 496 Location: USA
|
|
|
|
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 |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1249 Location: Richfield, MN, USA
|
|
|
|
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 |
|
|
|