Consultor Eletrônico



Kbase P111208: 4GL: How to convert the Timestamp value stored in the '_File.Last-Change' to date and time?
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   24/04/2009
Status: Unverified

GOAL:

How to convert the Timestamp value stored in the '_File.Last-Change' to date and time?

FIX:

The value stored in the '_File._Last-Change' field is the number of seconds elapsed since the start of the 'Progress Epoch' on January 1, 1970. The following code loops through all the user tables of a connected database and lists the table name, the Timestamp, stored in the filed '_File._Last-Change' field, the date of last change of the table and the time of that last change:
DEFINE VARIABLE iSecondsPerDay AS INTEGER NO-UNDO.
DEFINE VARIABLE dLastTableChangeDate AS DATE NO-UNDO.
DEFINE VARIABLE cLastTableChangeTime AS CHARACTER NO-UNDO.
ASSIGN
iSecondsPerDay = 24 * 60 * 60.
/* The field _File._Last-Change stores the elapsed number of seconds */
/* since the start of the Progress Epoch on January 1, 1970 */
FOR EACH _File NO-LOCK WHERE _Tbl-Type = "T":
ASSIGN
dLastTableChangeDate = 01/01/1970 + (_File._Last-Change / iSecondsPerDay)
cLastTableChangeTime = STRING(_File._Last-Change MOD iSecondsPerDay, "HH:MM:SS").
DISPLAY
_File-Name LABEL "Name" FORMAT "X(15)"
_Last-Change LABEL "Time Stamp" FORMAT "-ZZZZZZZZZZ"
dLastTableChangeDate LABEL "Last Date" FORMAT "99/99/9999"
cLastTableChangeTime LABEL "Last Time"
WITH STREAM-IO.
END.