DateConvert Complex Form

Syntax

DATECONVERT date_variable [ {+ | -}date_varible ] FORMAT format  
[ variable FORMAT format | EDITONLY ] [GS status]

Parameters

DateConvert can be abbreviated as DC.

Description

The complex form of the DateConvert logic command converts the value of a variable, storing the result in a series of built-in segment attributes with the prefix Glb.DC_, or in a single variable in a specified format.

The conversion is based on a base date defined by the Glb.Base, Glb.Century, and Glb.Century_Start built-in segment attributes. .

The complex form of the DateConvert logic command can be used to:

Note: Historic dates are not adjusted for past changes in the calendar.

Failure behavior

A date is invalid if:

Note: The Glb.Century built-in segment attribute can be automatically set to ensure the validity of the date. Refer to DateConvert Base Date.

If the date is invalid, the Glb.Status built-in segment attribute is set to "*****". Use the GS command option to direct the result to a variable. Error testing should be used whenever the DateConvert logic command is invoked.

If the Glb.Status built-in segment attribute is set to "*****", the DateConvert logic command is still executed, but uses the current date. If the current date is invalid (for example, it is prior to the start of the base year), then January 1 of the base year is used as input.

Restrictions

The following restrictions apply to use of the complex form of the DateConvert logic command:

Examples

Example 1

This example converts the Prod.Ord_DayNum relative day number. The result is stored in the Glb.DC_ built-in segment attributes.

DateConvert Prod.Ord_DayNum Format DAYNUM

Example 2

This example converts the Tran_Date date, in YYMMDD format, into CCYY-MMM-DD format, and stores it in DB_Date.

DateConvert Tran_Date Format YYMMDD DB_Date Format CCYY-MMM-DD

Example 3

This example sets Glb.Century to 19 prior to converting Tran_Date, in YYMMDD format. The result is stored in the Glb.DC_ built-in segment attributes.

Glb.Century := 19
DateConvert Tran_Date Format YYMMDD

Example 4

This example converts the date, 45 days after OrderDay, into DAYNUM format. The result is stored in the Glb.DC_ built-in segment attributes.

DateConvert OrderDay + 45 Format DAYNUM

Example 5

This example converts the date, Num_Days before Glb.Today, into YYMMMDD format. The result is stored in the Glb.DC_ built-in segment attributes.

Note: If Num_Days is a signed value, its sign is ignored.

DateConvert Glb.Today – Num_Days Format YYMMMDD

Example 6

This example validates Tran_Date in YYMMDD format. There is no output conversion.

DateConvert Tran_Date Format YYMMDD EditOnly

DateConvert Base Date

The conversion performed by the DateConvert complex form is based upon a base date defined by the Glb.Base, Glb.Century, and Glb.Century_Start built-in segment attributes.

Glb.Base and Glb.Century_Start

Set the Glb.Century_Start built-in segment attribute using the segment's Century Start Year property. If this property is not set, the Glb.Century_Start built-in segment attribute is set using the Glb.Base built-in segment attribute.

Set the Glb.Base built-in segment attribute using the segment's BaseYear property. The valid range is 1 through 9999. If this property is not set, the Glb.Base built-in segment attribute is set to 1957.

Glb.Century

The Glb.Century built-in segment attribute is set if the input date of the DateConvert logic command does not contain the century (it is a six-digit date). This is required if the century of the input date is different from the default century.

The Glb.Century built-in segment attribute is set to the next century if the year is less than the Glb.Century_Start built-in segment attribute, and either of the following conditions is true:

The Glb.Century built-in segment attribute is reinitialized in the Construct method, which is normally, but not always, called for each transaction. To ensure consistent results, set the Glb.Century built-in segment attribute to zero before using the DateConvert logic command to deduce the century.

Restrictions

The current century, instead of the Glb.Century built-in segment attribute, is used for the Glb.Today, Glb.Todays_Date_Num, Glb.YYMMDD, and built-in segment attributes and Input_Date built-in ispec attribute (except if it is from a database record).

Example

In this example, the Glb.Century_Start built-in segment attribute is set to 1957 (the same as the Glb.Base built-in segment attribute value) and the Glb.Century built-in segment attribute value is set to 0 (or 19).

If a DateConvert logic command is invoked with a year 50 followed by years of 60 and 70, and the segment's DC Sets Glb.Century property is set to true, the Glb.Century built-in segment attribute is set to 20 (since 1950 is prior to the value of Glb.Century_Start), and the years are interpreted as 2050, 2060, and 2070.

DateConvert Variable Format

The following table lists valid formats specified with the Format command parameter of the DateConvert complex form.

Note: Examples assume a Glb.Base value of 1957.

Format

Length

Primitive

Layout

Example

DAYNUM

6

Number

nnnnnn

15788

UK-ALPHA

25

String

DDbMMMMMMbCCYY

23 MARCH 2000

US-ALPHA

25

String

MMMMMMbDDbCCYY

MARCH 23 2000

IN-ALPHA

25

String

CCYYbMMMMMMbDD

2000 MARCH 23

DD-MM-YY

8

String

DD/MM/YY

23/03/00

DD-MM-CCYY

10

String

DD/MM/CCYY

23/03/2000

DD-MMM-YY

9

String

DDbMMMbYY

23 MAR 00

DD-MMM-CCYY

11

String

DDbMMMbCCYY

23 MAR 2000

DDMMMYY

7

String

DDMMMYY

23MAR00

DDMMMCCYY

9

String

DDMMMCCYY

23MAR2000

DDMMYY

6

Number

DDMMYY

230300

DDMMCCYY

8

Number

DDMMCCYY

23032000

MM-DD-YY

8

String

MM/DD/YY

03/23/00

MM-DD-CCYY

10

String

MM/DD/CCYY

03/23/2000

MMDDYY

6

Number

MMDDYY

032300

MMDDCCYY

8

Number

MMDDCCYY

03232000

MMM-DD-YY

9

String

MMMbDDbYY

MAR 23 00

MMM-DD-CCYY

11

String

MMMbDDbCCYY

MAR 23 2000

MMMDDYY

7

String

MMMDDYY

MAR2300

MMMDDCCYY

9

String

MMMDDCCYY

MAR232000

YY-MM-DD

8

String

YY/MM/DD

00/03/23

CCYY-MM-DD

10

String

CCYY/MM/DD

2000/03/23

YY-MMM-DD

9

String

YYbMMMbDD

00 MAR 23

CCYY-MMM-DD

11

String

CCYYbMMMbDD

2000 MAR 23

YYDDD

5

Number

YYDDD

00083

CCYYDDD

7

Number

CCYYDDD

2000083

YYMMDD

6

Number

YYMMDD

000323

CCYYMMDD

8

Number

CCYYMMDD

20000323

YYMMMDD

7

String

YYMMMDD

00MAR23

CCYYMMMDD

9

String

CCYYMMMDD

2000MAR23

TODAY

15

String

(day name)

THURSDAY

WEEKNO (result only)

2

Number

nn

13