$DateChg

From m204wiki
Jump to navigation Jump to search

The $DateChg function adds or subtracts a specified number of days from a given date. The result is returned in the format of the input date.

Syntax

The format of the $DateChg function is:

$DateChg(format, date, number-of-days)

Where:

  • format specifies the format of the input date. The format can be a combination of these elements:
    DD Gregorian numeric day
    DDD Julian numeric date
    MM Numeric month
    MON Abbreviated month name
    MONTH Full month name
    YY Last two digits of numeric year (assumes that the year prefix is 19)
    YYYY Full numeric year
    CYY The century, plus the year. Century (C) is a single digit, where 0 represents 1900, 1 represents 2000, and so on.

    Valid formats are:

    • A format that has a month, day, and year element
    • A Julian date format that has a year element and a day element in the format DDD
    • Any EBCDIC characters except single quotes are allowed within the format. The format can be as many as 32 characters in length.
  • date specifies a date in the format indicated by the format argument. The date can be as many as 36 characters in length.
  • number-of-days indicates the number of days to be added or deducted from the date. The number must be an integer.

Separators and leading zeros

  • The separators in the format argument must match the separators in the date argument. For example:

    $datechg('MONTH - DD - YYYY','JANUARY - 05 - 1996', 20)

  • When necessary, you must pad the month or date in the date argument with leading zeros to match the length of the format. For example:
  • $datechg('YY DDD','96 023',22)

How $DateChg works

  • If the number of days is a positive integer, the number is added to the date.
  • If number of days is a negative integer, the number is deducted from the date.
  • If an error occurs, all asterisks (*) are returned.

Example

The following statement:

Print $datechg('MON. DD, YYYY','JAN. 10, 2009', 15)

Prints this value:

JAN. 25, 2009