SORT records on date.

SyncSort's Sort Product, SyncTool for z/OS, SYNCINIT and SYNCLIST.
Post Reply
SarvanaL
New Member
Posts: 3
Joined: Wed Sep 09, 2015 5:53 pm

SORT records on date.

Post by SarvanaL »

Hi,

I need to sort the records in a dataset based on date in ascending order. If there are three dates namely 31.1.1998, 2.12.1997,3.6.2014 then output should have 2.12.1997,31.1.1998,3.6.2014

I have used the sort card:

Code: Select all

SORT FIELDS =(60,10,UFF,A) 


But the records are not getting sorted properly. Can you guys please suggest how to solve it.
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1886
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: SORT records on date.

Post by Robert Sample »

What format are the dates in? You cannot put together a SORT statement without knowing that. Whatever the format, you'll want to sort by year, month, day to get the data in ascending date sequence.
William Collins
Global Moderator
Global Moderator
Posts: 490
Joined: Sun Aug 25, 2013 7:24 pm

Re: SORT records on date.

Post by William Collins »

You'll need to PARSE the fields in INREC, then make a temporary extension to the record. Heed Robert's point about sorting in a logical order (year, month, day).

In OUTREC, use BUILD to return the record to its original size.
SarvanaL
New Member
Posts: 3
Joined: Wed Sep 09, 2015 5:53 pm

Re: SORT records on date.

Post by SarvanaL »

Robert Sample wrote:What format are the dates in? You cannot put together a SORT statement without knowing that. Whatever the format, you'll want to sort by year, month, day to get the data in ascending date sequence.
Dates are in DD.MM.YYYY format.
SarvanaL
New Member
Posts: 3
Joined: Wed Sep 09, 2015 5:53 pm

Re: SORT records on date.

Post by SarvanaL »

William Collins wrote:You'll need to PARSE the fields in INREC, then make a temporary extension to the record. Heed Robert's point about sorting in a logical order (year, month, day).

In OUTREC, use BUILD to return the record to its original size.
Thanks but what are you saying when you say "a temporary extension to the record"?
nicc
Global Moderator
Global Moderator
Posts: 691
Joined: Wed Apr 23, 2014 8:45 pm

Re: SORT records on date.

Post by nicc »

Internally to sort records can be made longer so if you have an 80 byte record and you want to add your reformatted date (CCYYMMDD) you would ask sort to put it in columns 81-88 (for VB records you extend by inserting the extension after the RDW and before the first byte of 'real' data. You the sort on that added data and remove it when writing the output.
Regards
Nic
enrico-sorichetti
Global Moderator
Global Moderator
Posts: 825
Joined: Wed Sep 11, 2013 3:57 pm

Re: SORT records on date.

Post by enrico-sorichetti »

if as reported by the TS
Dates are in DD.MM.YYYY format.
in a fixed position

why complicate things ?

Code: Select all

SORT FIELDS=(year_start_column,4,CH,A,month_start_column,2,CH,A,day_start_column,2,CH,A)
should be more than enough
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort 8-)
William Collins
Global Moderator
Global Moderator
Posts: 490
Joined: Sun Aug 25, 2013 7:24 pm

Re: SORT records on date.

Post by William Collins »

The sample data shown is 31.1.1998, 2.12.1997, 3.6.2014. Hence the need to PARSE (assuming the data shown is correct and the description of the data is not, strictly).
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “SyncSort, SyncTool, SyncGener.”