Previous Topic: CountNext Topic: Date Difference


Date Change

The date change functions return the conversion of a specified date from one format (Gregorian, calendar, European, or Julian) to another.

Syntax:

►►─┬─ DATECHG (date, 'input-date-format', 'output-date-format') ─┬────────────►◄
   └─┬─ GCDATE ─┬─ (date) ───────────────────────────────────────┘
     ├─ GEDATE ─┤
     ├─ GJDATE ─┤
     ├─ CGDATE ─┤
     ├─ CEDATE ─┤
     ├─ CJDATE ─┤
     ├─ EGDATE ─┤
     ├─ ECDATE ─┤
     ├─ EJDATE ─┤
     ├─ JGDATE ─┤
     ├─ JCDATE ─┤
     └─ JEDATE ─┘
►►─┬─ DATECHGX (century-date, 'input-date-format', 'output-date-format') ─┬───►◄
   └─┬─ GCDATEX ─┬─ (century-date) ───────────────────────────────────────┘
     ├─ GEDATEX ─┤
     ├─ GJDATEX ─┤
     ├─ CGDATEX ─┤
     ├─ CEDATEX ─┤
     ├─ CJDATEX ─┤
     ├─ EGDATEX ─┤
     ├─ ECDATEX ─┤
     ├─ EJDATEX ─┤
     ├─ JGDATEX ─┤
     ├─ JCDATEX ─┤
     └─ JEDATEX ─┘

Invocation names:

               DATECHG                              DATECHGX
GCDATE    CGDATE   EGDATE   JGDATE   GCDATEX    CGDATEX   EGDATEX   JGDATEX
GEDATE    CEDATE   ECDATE   JCDATE   GEDATEX    CEDATEX   ECDATEX   JCDATEX
GJDATE    CJDATE   EJDATE   JEDATE   GJDATEX    CJDATEX   EJDATEX   JEDATEX

Parameters:

date

Specifies the six-byte object date for the date change function.

Date can be:

century-date

Specifies the eight-byte object date (containing the century) for the date change function.

Century date can be:

'input-date-format'

Specifies the format of the date specified by date or century-date.

Input date can be:

'output-date-format'

Specifies the format to which date or century-date is to be converted.

Output date can be:

Examples:

Example 1

In this example, the date change function is used to convert January 28, 1958, from Gregorian to calendar format:

compute calendar = datechg(580128,'g','c') group by all

  012858

Example 2

In this example, the date change function is used to convert November 12, 1991, from Julian to Gregorian format. The returned date contains the century portion of the year:

compute calendar = jgdate(91316,'j','g')

  911112

Example 3

In this example, the date change function is used to convert January 28, 1958, from Gregorian to calendar format. The returned date contains the century portion of the year:

compute calendar = datechgx(19580128,'g','c') group by all

  01281958