+ Datetime addition operator
- Last Updated: January 18, 2024
- 1 minute read
- OpenEdge
- Version 12.8
- Documentation
Adds a number of milliseconds to a DATETIME or a DATETIME-TZ to produce another DATETIME or DATETIME-TZ.
Syntax
|
|
- datetime
- An expression that evaluates to a DATETIME value.
- milliseconds
- An expression that evaluates to an integer value specifying a number of milliseconds.
- datetime-tz
- An expression that evaluates to a DATETIME-TZ value.
Example
This
example returns the date and time exactly 24 hours later (dtTime)
by calculating and adding the number of milliseconds in 24 hours
to the present date and time (NOW function) and displays the result:
|
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 addition operator, - Datetime subtraction operator, ADD-INTERVAL function, DATETIME function, DATETIME-TZ function