Using Full-Date Formats with CENTWIN - mfx - 3.1

Syncsort™ MFX Programmers Guide

Product type
Software
Portfolio
Integrate
Product family
Syncsort™ Software
Product
Syncsort™ MFX > MFX
Version
3.1
Language
English
Content type
Programmer’s Guide
Product name
Syncsort™ MFX
Title
Syncsort™ MFX Programmers Guide
Copyright
2024
First publish date
2010
Last updated
2024-08-27
Published on
2024-08-27T08:14:56.318001

MFX’s full-date data formats enable you to sort or merge a variety of date fields. The full-date formats are Y2T, Y2U, Y2V, Y2W, Y2X, and Y2Y. These date formats can process dates ending or starting with year digits:

  • x...xyy (for example: qyy, mmyy, dddyy, or mmddyy)

  • yyx...x (for example: yyq, yymm, yyddd, or yymmdd)

The full-date formats also process non-date data commonly used with the dates. MFX interprets two-digit years (yy) according to the century window specified by the CENTWIN option. CENTWIN processing does not apply to non-date data.

In most cases, for CH, ZD, and PD date fields the full-date data formats are easier to use than the 2-digit date formats. The 2-digit formats can be more difficult because you must divide the date into its components. This requires care, particularly for PD dates, where date components (q, dd, mm, or yy) may span bytes or occupy only part of a byte. The full-date formats, on the other hand, process such dates automatically.

The table below describes the full-date formats. For date forms not in the table, use the 2-digit year formats or the non-year formats.

Note the following symbols used in the table:

y      year digit (0-9)

x      non-year digit (0-9)

s      sign (hexadecimal A-F)

0      unused digit

Table 1. Full-Date Formats

Full-Date

Format

Data

Format

Date Form

Example Date Form

Length (bytes)

 Y2T

CH, BI

yyx

yyq

3

yyxx

yymm

4

yyxxx

yyddd

5

yyxxxx

yymmdd

6

Y2U

PD

yyx

(X'yyxs')

yyq

2

yyxxx

(X'yyxxxs')

yyddd

3

Y2V

PD

yyxx

(X'0yyxxs')

yymm

3

yyxxxx (X'0yyxxxxs')

yymmdd

4

Y2W

 

CH, BI

xyy

qyy

3

xxyy

mmyy

4

xxxyy

dddyy

5

xxxxyy

mmddyy

6

Y2X

PD

xyy

(X'xyys')

qyy

2

xxxyy

(X'xxxyys')

dddyy

3

Y2Y

PD

xxyy

(X'0xxyys')

mmyy

3

xxxxyy (X'0xxxxyys')

mmddyy

4

The table indicates the full-date formats that can be used with character (CH), binary (BI), or packed decimal (PD) data. Note the recognized non-date values:

Character or binary (Y2T and Y2W full-date formats)

C'0...0' (CH zeros)

C'9...9' (CH nines)

Z'0...0' (ZD zeros)

Z'9...9' (ZD nines)

X'00...00' (BI zeros)

X'40...40' (blanks)

X'FF...FF' (BI ones)

Packed (Y2U, Y2V, Y2X, and Y2Y full-date formats)

P'0...0' (PD zeros)

P'9...9' (PD nines)

The following two examples illustrate how you might use Full-Date Formats:

  • Suppose you have a packed decimal (PD) date field of the form mmyy. To sort this field correctly, you would use the Y2Y 3-byte format from the table. Thus, if the field starts in position 30, you would specify the following SORT control statement to sort in descending order:

    SORT FIELDS=(30,3,Y2Y,D)

    Any PD fields of all PD zeros or all PD nines will be processed automatically as non-date data.

  • Suppose you have a character (CH) date field of the form yymmdd. To sort this field correctly, you would use the Y2T 6-byte format from the table. Thus, if the field starts in byte 40, you would specify the following SORT control statement to sort in ascending order:

    SORT FIELDS=(40,6,Y2T,A)

    Any CH zeros, CH nines, BI zeros, blanks, and BI ones will be processed automatically as non-date data.

    Collating Sequence with Full-Date Formats

    For full-date formats, the yy component is always sorted first (treated as primary key). This is so even when the yy is physically at the rightmost end of the field, as for Y2W, Y2X, and Y2Y. For example, a 6-byte Y2W field has the form xxxxyy. This is collated with the yy as the primary key and xxxx as the secondary key. Because MFX automatically collates the year character first, you don’t have to deal with yy manually, for example by using PD0 and Y2D.

    It is important to understand that the xxxx component of a full-date format must be designed to collate as a unit. Suppose you have the 6-byte Y2T field yyxxxx. If you collate this field in ascending order, then yy collates first (the primary key) with xxxx collating second (secondary key). Consider two possibilities:

  • If yyxxxx is actually yymmdd, you will be sorting first by year, then month, then day.

  • If yyxxxx is actually yyddmm, you will sorting by year, then day, then month. In most cases, sorting in this way would not be what you intended.

    To correctly collate a date, the date components must be in an order suitable for collating. For example, mmddyy and yymmdd will collate correctly, but ddmmyy or yyddmm will not. For date forms that will not collate correctly, you must use one of the 2-digit year formats (Y2B, Y2C, Y2D, Y2P, Y2S, and Y2Z).

The following table shows the order for ascending collation when using full-date formats with the CENTWIN option:

Table 2. Full-Date Formats, Ascending Collation

Full-Date Format

Date Format

Ascending Sort Sequence

Y2T

Y2W

CH, BI

BI zeros

Blanks

CH/ZD zeros

Lower century dates (e.g. 1980)

Higher century dates (e.g. 2010)

CH/ZD nines

BI ones

Y2U

Y2V

Y2X

Y2Y

PD

PD zeros

Lower century dates (e.g. 1980)

Higher century dates (e.g. 2010)

PD nines

For a descending sort, the collation order is reversed.

Other date formats (non-full-date), with the exception of Y2S, do not process non-date data; their sort sequence for ascending sorts is simply lower century dates than higher century dates.