Hi there!
I need to get the TIME part of a DATE-TIME field, and make STRING() to it, so I can show it in a readable form to the user?
I don't know if this is the easiest way but this knowledgebase article shows one method.
knowledgebase.progress.com/.../P75847
DEF VAR tsdate AS DATETIME.
/* Put a datetime value in tsdate variable */
/* equivalent to Assign tsdate = NOW. */
ASSIGN tsdate = DATETIME( TODAY, MTIME ).
/* display the time portion of the datetime variable with format HH:MM:SS:NNN where NNN are the milliseconds */
DISPLAY tsdate
STRING( INTEGER( truncate( MTIME( tsdate ) / 1000, 0 ) ), "HH:MM:SS" ) + ":" + STRING( MTIME(tsdate) MODULO 1000, "999" ) FORMAT "x(16)".
mmh.. I didn't wanted to do someting like:
STRING( INTERVAL (now, datetime(today, 0), "seconds"), "HH:MM:SS")
as I tought it was "un-elegant"
Thanks!!!
Anyway..
Depending on your date/time format:
DEFINE VARIABLE dtDate AS DATETIME NO-UNDO.
ASSIGN dtDate = NOW.
MESSAGE ENTRY(2, STRING(dtDate, "99/99/9999 HH:MM"), " ") SKIP
ENTRY(2, STRING(dtDate), " ")
VIEW-AS ALERT-BOX INFO BUTTONS OK.
You can actually use MTIME...
Like:
MESSAGE STRING(INTEGER(MTIME(NOW) / 1000),"HH:MM:SS")
VIEW-AS ALERT-BOX INFO BUTTONS OK.