DATEOFF

Returns the date resulting from adding a specified number of days to a specified date.
idmscu19
Returns the date resulting from adding a specified number of days to a specified date.
This article describes the following information:
2
2
Syntax
  ►►─┬─ DATEOFF ──┬─ ( 
gregorian-date, offset
 ) ────────────────────────────────►◄    └─ DATEOFFX ─┘  
Parameters
  • DATEOFF/DATEOFFX
    Invokes the date offset function. DATEOFFX operates on values that contain the century portion of the year.
  • gregorian-date
    Specifies the date, in Gregorian format, to which the offset is added.
    Gregorian-date
    can be:
    • The name of a user-defined variable data field
    • A user-supplied numeric literal
  • offset
    Specifies the offset, in days, that is added to the specified date.
    Offset
    can be:
    • The name of a user-defined variable data field
    • A user-supplied numeric literal
    • A built-in function that returns a numeric value
    Offset
    can be negative.
Usage
DATEOFF assumes the twentieth century if the year is greater than 68, and assumes the twenty-first century if between 0 and 68. DATEOFFX allows a computation to be made in any century.
DATEOFFX assumes a continuous algorithm using the modern Gregorian calendar. It does not contain tables for historical aberrations.
Anytime a signed literal is used with DATEOFF, it should be enclosed within single quotes like this:
MOVE DATEOFF(911119,'-1') TO EXP-DATE
Examples
Example 1
In the following example, the date offset function is used to find the date that results from adding four days to January 28, 1978:
Statement:     MOVE DATEOFF(780128,4) TO WK-RESULT. Returned value: 780201
Example 2
In this example, the date offset function is used to find the date that results from adding five days to December 28, 1999.
Gregorian-date
contains the century portion of the year, as does the returned date.
Statement:     MOVE DATEOFFX(19991228,5) TO WK-RESULT. Returned value: 20000102