Consultor Eletrônico



Kbase P125815: How to convert stored DATETIME-TZ value to local time
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   4/12/2011
Status: Verified

GOAL:

How to convert stored DATETIME-TZ value to local time

GOAL:

Display a date time value that has been stored in the database in local time

FACT(s) (Environment):

OpenEdge 10.x
All Supported Operating Systems

FIX:

When a value is stored in a DATETIME-TZ field in a database/temp-table OpenEdge will automatically normalize the value into local time for you. Simply assign it to a local variable and display the local variable.
Example:
DEFINE VARIABLE dtLocalTime AS DATETIME NO-UNDO.
DEFINE TEMP-TABLE timeEntry NO-UNDO
FIELD tdtEntryTime AS DATETIME-TZ.
CREATE timeEntry. /* Store a bunch of Datetime-TZ values in GMT format */
timeEntry.tdtEntryTime = DATETIME-TZ(NOW,0).

FIND FIRST timeEntry NO-LOCK NO-ERROR.
IF AVAILABLE timeEntry THEN DO:
dtLocalTime = timeEntry.tdtEntryTime.
MESSAGE "Stored Time: " timeEntry.tdtEntryTime SKIP
"Local Time: " dtLocalTime
VIEW-AS ALERT-BOX.
END.