Skip to content
CA NetMaster® Shared Content Library - 12.1
Documentation powered by DocOps

&DATECONV

Last update April 17, 2015

The &DATECONV built-in function does either of the following:

  • Converts one date format to another.

    &DATECONV DATEx date [ = ] DATEy [ variation ]

  • Subtracts two dates.

    &DATECONV DATEx date1 - DATEy date2

&DATECONV must be used to the right of an assignment statement.

You can use &DATECONV to reformat a date from one NCL date form to another NCL date form. In addition, you can optionally adjust the date by a number of days.

You can also use &DATECONV to subtract two dates.

DATEx formats are shown in the following table:

DATEx Format DATEx Format
x = 1
2
3
4
5
6
7
8
YY.DDD
DAY DD-MON-YYYY
DD-MON-YYYY
DD/MM/YY
MM/DD/YY
YY/MM/DD
YYMMDD
YYYYMMDD
x = 9
10
11
12
13
14
16
17
nnnnnn (days since 1/1/0001)
YYYYMMDDHHMMSSpHHMM
YYYYMMDDHHMMSS.FFFFFFpHHMM
DD/MM/YYYY
YYYY/MM/DD
MM/DD/YYYY
YYYY.DDD
YYYYDDD

For date 10, p in the format is plus (+) or minus (-).

For date 11, YYYYMMDDHHMMSS is local time. p is plus (+) where local time is ahead of GMT; otherwise, p is minus (-). HHMM is the offset for GMT.

Operands:

For reformatting a date from one NCL date form to another NCL date form, this built-in function has the following format:

&result = &DATECONV DATEx &indate [ = ] DATEy [ variation ]

  • DATEx
    Indicates the date format for the input date (that is, the date to convert) where x is a number. The format of the date is the same as the format of the date returned by the corresponding &DATEn system variable. See the previous table for the actual formats supported.
  • date1
    A date string with format DATEx, specifying the input date.
  • DATEy
    The date format required after the conversion. This format must be one of the NCL supported date formats &DATE1 to &DATE17 (excluding &DATE15).
  • variation
    Specifies the number of days to vary the converted date, with respect to the original date. This variation is positive or negative, with NO space allowed anywhere from the sign to the end of the value. The variation can also be used to add or subtract a value, using the following format:

    { + | - }dddd.hhmmss.ffffff

    This format must begin with a sign, followed by the number of days (any integer including 0 up to 2147483647 is acceptable), then optionally a period followed by hours, minutes and seconds, and optionally fractions of a second to microseconds. This operand is useful when using DATE10 and DATE11 formats to determine the exact date and time for some future or past interval.

For subtracting two dates, this built-in function has the following format:

&result = &DATECONV DATEx date1 - DATEy date2

  • DATEx
    The format of the first date, where x is a number. The format of the date is the same as the format of the date returned by the corresponding &DATEn system variable. This format must be one of the NCL supported date formats &DATE1 to &DATE17 (excluding &DATE15). See the previous table for the actual formats supported.
  • date1
    A date string with format DATEx, specifying the first date.
  • DATEy
    The format of the second date format, where y is a number. The format of the date is the same as the format of the date returned by the corresponding &DATEn system variable. This format must be one of the NCL supported date formats &DATE1 to &DATE17 (excluding &DATE15). See the previous table for the actual formats supported.
  • date2
    A date string with format DATEx, specifying the second date.
    The value returned is date1 - date2, where the sum or difference is one of the following forms:
    • { + | - } dddd
    • { + | - } ddddhhmmss
    • { + | - } dddd.hhmmss
    • { + | - } dddd.hhmmss.ffff
    • { + | - } ddddhhmmssffffff
    The form where .hhmmss is present is returned only if either input date is DATE10, while .hhmmss.ffffff is returned only if either input date is DATE11. dddd is an integer with a maximum absolute value of 2,147,483,647.
    If you specify an invalid source date format or value, or if the resultant date exceeds the maximum date supported (that is, 31st December 2099) the target variable is set to nulls.

Examples:

&TODAY = &DATE1 &YESTERDAY = &DATECONV DATE1 &TODAY DATE2 -1

converts the system date of today (format YY.DDD), to the system date of yesterday (format DAY DD-MMM-YYYY)

&UPDATED = 90.360 &UPDATED = &DATECONV DATE1 &UPDATED DATE2

converts &UPDATED to WED 26-DEC-1990

&EXPIRES = 32.360 &EXPIRES = &DATECONV DATE1 &EXPIRES DATE2

converts &EXPIRES to SAT 25-DEC-2032

Notes:

&DATECONV lets you present date formats consistently for individual users, or systemwide. NCL procedures can be written using a standard internal date format. This format can then be tailored for system users depending upon other parameters such as language codes.

When converting from date formats with a two-digit year (YY) to a format with a four-digit year, the century is assumed as follows:

  • If the year number (YY) for the original source variable is less than 50, the century is calculated as 20.
  • If the original year (YY) is greater than or equal to 50, the century is calculated as 19.

When adjustment by a specific variation crosses the century boundary, the adjustment is performed first and the century of the resultant yy value is determined as described previously.

When the target date is DATE11, the output is normalized to be GMT with the system zone offset.

In general, the input and output dates are assumed to be local dates and times. If the input date is either DATE10 or DATE 11, the resultant date is calculated by taking into account the difference between the input time zone and the local time zone.

For example, if the local time zone is +1000:

&DATECONV DATE10 19920630143622+0000 DATE2

produces a result of WED 01-JUL-1992.

Was this helpful?

Please log in to post comments.