Try OpenEdge Now
skip to main content
ABL Reference
ABL Syntax Reference : + Date addition operator
 

+ Date addition operator

Adds a number of days to a date, producing a date result.

Syntax

date + days
date
An expression that evaluates to a DATE value.
days
An expression with a value of the number of days you want to add to a date.

Example

The r-dadd.p procedure finds all unshipped orders that are at least one week overdue. If the order is not shipped and the promised date is more than seven days ago, the procedure finds the record for the customer who placed the order and displays the order and customer data.
r-dadd.p
DISPLAY "ORDERS SCHEDULED TO SHIP MORE THAN ONE WEEK LATE".
FOR EACH Order NO-LOCK WHERE Order.ShipDate = ?:
  IF TODAY > (Order.PromiseDate + 7) THEN DO:
    FIND Customer OF Order NO-LOCK.
    DISPLAY Order.OrderNum Order.CustNum Customer.Name Order.PromiseDate
      Customer.Terms.
  END.
END.

Notes

*To add a specific number of days and a specific number of milliseconds to a DATETIME, use the DATETIME function. For example:
new-datetime = DATETIME( DATE(old-datetime) + days,
                         MTIME(old-datetime) + milliseconds ).
The DATETIME function ensures that the time portion remains within the valid range, by adding day(s) to the date part when the time part goes over the number of milliseconds in a day.
*To add a specific number of days and milliseconds to a DATETIME-TZ, use the DATETIME-TZ function. For example:
new-datetime-tz = DATETIME-TZ( DATE(old-datetime-tz) + days,
                               MTIME (old-datetime-tz) + milliseconds,
                               TIMEZONE(old-dateime-tz) ).
The DATETIME-TZ function ensures that the time portion remains within the valid range, by adding day(s) to the date portion when the time part goes over the number of milliseconds in a day.

See also

- Date subtraction operator, + Datetime addition operator, ADD-INTERVAL function, DATE function