Add, subtract, and obtain specific time intervals
- Last Updated: December 3, 2025
- 1 minute read
- OpenEdge
- Version 12.8
- Documentation
The ADD-INTERVAL function adds a time
interval to, or subtracts a time interval from, a DATE, DATETIME,
or DATETIME-TZ value using the following syntax:
Syntax
|
To subtract dates and times, you use the ADD-INTERVAL function
with an INTEGER value for the interval amount,
and a unit of time (such as minutes, days, or weeks) for the interval
unit. The result is a different DATE, DATETIME,
or DATETIME-TZ value, depending on the data type
of datetime.
Here is an example that adds two days to the order date to determine the estimated ship date:
|
Starting with Release 10.1B, you can subtract two datetimes,
giving an INT64 with the number of milliseconds.
The INTERVAL function returns the time interval between
two DATE, DATETIME, or DATETIME-TZ values
using the following syntax:
Syntax
|
The result is a the number of specified units (for example, minutes, days, or weeks) between the specified values date or datetime values.
The return data type of INTERVAL is INT64.
Here is an example that uses the INTERVAL function
to determine if an order shipped on time:
|
In this example, the ship datetime should be five days after the order date.
The following example using ADD-INTERVAL and INTERVAL shows
time-interval calculations with date and datetime values that produce
results in milliseconds.
|