Kbase P81379: How to determine the difference between two DATETIME(-TZ)s ?
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  3/2/2010 |
|
Status: Verified
GOAL:
How to determine the difference between two DATETIME(-TZ)s ?
GOAL:
How to compare DATETIME(-TZ) variables ?
FACT(s) (Environment):
OpenEdge 10.x
All Supported Operating Systems
FIX:
Currently, there is no easy way to add or subtract DATETIME(-TZ) variables directly.
To calculate the difference between two DATETIME(-TZ)s, extract the date and time components separately using the DATE and MTIME functions, and compare these components individually.
Example: DEFINE VARIABLE dtOne AS DATETIME-TZ.
DEFINE VARIABLE dtTwo AS DATETIME-TZ.
dtOne = NOW.
dtTwo = DATETIME-TZ(TODAY + 5, (TIME + 511) * 1000).
MESSAGE dtOne SKIP
dtTwo SKIP
"Difference: " DATE(dtTwo) - DATE(dtOne) " days and " (MTIME(dtTwo) - MTIME(dtOne)) / 60000 " minutes"
VIEW-AS ALERT-BOX INFO BUTTONS OK.
Keep in mind that the time portion of the DATETIME(-TZ) datatype is stored in milliseconds.