PreviousNextIndex

– Datetime subtraction operator

Subtracts a number of milliseconds from a DATETIME or a DATETIME-TZ to produce another DATETIME or DATETIME-TZ, or subtracts one DATETIME or DATETIME-TZ from another to produce an INT64 result in milliseconds.

Syntax

datetime - { milliseconds | datetime } 

datetime-tz - { milliseconds | datetime-tz } 

datetime
milliseconds
datetime-tz
Example

This example returns the date and time exactly 24 hours ago (dtTime). It then recalculates the number of hours (iHours) from the number of milliseconds (iMsec) since then and displays the result:

DEFINE VARIABLE dtTime AS DATETIME NO-UNDO. 
DEFINE VARIABLE iMsec  AS INT64    NO-UNDO. 
DEFINE VARIABLE iHour  AS INTEGER  NO-UNDO INITIAL 3600000. 
DEFINE VARIABLE fHours AS DECIMAL  NO-UNDO. 
ASSIGN 
  dtTime = NOW - (24 * iHour) 
  iMsec  = NOW - DATETIME-TZ(dtTime) 
  fHours = iMsec / iHour. 
MESSAGE "A day earlier: " dtTime "  "  
        "Current hours since then: " fHours VIEW-AS ALERT-BOX. 

Notes
See also

– Date subtraction operator, + Datetime addition operator, ADD-INTERVAL function, DATETIME function, DATETIME-TZ function, INTERVAL function


OpenEdge Release 10.2B
Copyright © 2009 Progress Software Corporation
PreviousNextIndex