Consultor Eletrônico



Kbase P123330: Datetime(-tz) rounds milliseconds incorrectly if format does not include milliseconds
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   4/10/2007
Status: Unverified

FACT(s) (Environment):

OpenEdge 10.0x
OpenEdge 10.1A
OpenEdge 10.1B

SYMPTOM(s):

DATETIME or DATETIME-TZ value displayed or converted to string

Format used for DATETIME(-TZ) does not include milliseconds

Milliseconds are rounded to the nearest second

Other time units (seconds and minutes) are always rounded down

CAUSE:

This is a known issue being investigated by Development

FIX:

Workaround:

A user-defined function such as the following can be used to discard the millisecond portion of the DATETIME(-TZ), so that it will be processed correctly:

FUNCTION DatetimeNoMS RETURNS DATETIME-TZ(INPUT dtzInput AS DATETIME-TZ):
RETURN DATETIME-TZ(DATE(dtzInput),
(MTIME(dtzInput) - MTIME(dtzInput) MOD 1000),
TIMEZONE(dtzInput) ).
END FUNCTION.

/* demo code */
DEFINE VARIABLE dtTest AS DATETIME NO-UNDO.
DEFINE VARIABLE cResult AS CHARACTER NO-UNDO.

dtTest = DATETIME(4, 5, 2007, 13, 59, 59, 999).
cResult = string(datetimeNoMS(dtTest),"99/99/9999 HH:MM:SS").

MESSAGE cResult VIEW-AS ALERT-BOX INFO BUTTONS OK.