× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.


  • Subject: Re: FMTDTA/#GSORT Challenge
  • From: Tim Truax <truax@xxxxxxxxx>
  • Date: Thu, 04 Dec 1997 00:23:07 -0500

Charles L. Massoglia wrote:
You have a 6 digit packed MMDDYY date in positions 1-4 of a file.  How do
you sort the date in YYMMDD order using FMTDTA or #GSORT?
Response #1----The sort specs below will sort a packed MMDDYY date field correctly.
The zone and digit portions are used to sort each date character.  If the
"extra" high order position is used for century, then it can also sort on
century.

Needless to say, it is always best to pack dates as YYMMDD.  Somebody will want
a date sort sooner or later.  Alas, that's hindsight.  So this will accomplish
the same thing for those old-fashioned files.

Hex representation:

...20....+...30
      CMDY
      MDYZ
 

Date Portion of Sort Specs:

6..10....+...20....+...30..
HSORTR     7A        0X  32
FNZ  22  22
FND  24  24
FNZ  25  25
FND  22  22
FNZ  23  23
FND  23  23
FND  24  24

William J. Ihle
Caro, Michigan

 

For extra credit, how to you select a range of dates in MMDDYY format, e.g.
120297 to 011598>

Response #2----The sort specs below will do the range sorting.

This example assumes the date field is in position 31 through 36 of the record.
I think this will accomplish what you are trying to do though someone else may
have a better way.
-------------------------------------------------------------------------------
Figure 1: Selecting Date Ranges with #GSORT

// LOCAL OFFSET-1,DATA-'?1R?'     Load first date into LDA
// LOCAL OFFSET-7,DATA-'?2R?'     Load second date into LDA
// LOAD #GSORT
// FILE NAME-INPUT,LABEL-RS.TRAN
// FILE NAME-OUTPUT,LABEL-OUTFILE,RECORDS-?F'A,RS.TRAN'?
// RUN
     HSORTR     6A        3X  84   N
     O C  10  11LTC?L'5,2'?      Omit years less than start year
     OOC  10  11EQC?L'5,2'?      Omit years same as start year
     OAC   6   9LTC?L'1,4'?        and MM/DD are less than start MM/DD
     OOC  10  11GTC?L'11,2'?     Omit years greater than end year
     OOC  10  11EQC?L'11,2'?     Omit years same as end year
     OAC   6   9GTC?L'7,4'?        and MM/DD are greater than end MM/DD
     I                           Include all else
     FNC  10  11                 Sort on year
     FNC   6   9                   then MM/DD
     FDC   1  84                 Include all data
// END
-------------------------------------------------------------------------------
Well there's my historic documented suggestions.
Do I get a free lottery ticket or something, thanks for the test of old-ability fluency.

--
:-) Tim & Dana Truax (-:
 


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.