Try OpenEdge Now
skip to main content
ABL Data Types Addenda
DATETIME and DATETIME-TZ data types : Datetime arithmetic : Adding and subtracting days plus milliseconds with a datetime value
 

Adding and subtracting days plus milliseconds with a datetime value

You can add or subtract days and milliseconds together with a datetime value using a combination of ABL functions, depending the data type (DATETIME or DATETIME-TZ). This is the syntax for adding or subtracting a specific number of days and milliseconds with a DATETIME:

Syntax

new-datetime = DATETIME( DATE( old-datetime ) { + | - }days ,
   MTIME( old-datetime ) { + | - }milliseconds ) .
The new-datetime value then represents a new DATETIME at a point later (when adding to) or earlier (when subtracting from) the old-datetime value by the specified number of days and milliseconds.
This is the syntax for adding or subtracting a specific number of days and milliseconds with a DATETIME-TZ:

Syntax

new-datetime-tz = DATETIME-TZ( DATE( old-datetime-tz ) { + | - }days ,
   MTIME( old-datetime-tz ) { + | - }milliseconds ,
   TIMEZONE( old-dateime-tz ) ) .
The new-datetime-tz value then represents a new DATETIME-TZ at a point later (when adding to) or earlier (when subtracting from) the old-datetime-tz value by the specified number of days and milliseconds within the specified time zone.