Cecil
19+ years progress programming and still learning.
I know of two ways to convert an ISO-DATE formatted string into a date datatype and I think both sucks! What is the best approach to importing ISO-DATE formatted strings into a date datatype. Is there some sort of secret Openedge function that I don't know about?
Code:
DEFINE VARIABLE isoDateFormatted AS CHARACTER NO-UNDO.
DEFINE VARIABLE DATE AS DATE NO-UNDO.
DEFINE VARIABLE dateYear AS INTEGER NO-UNDO.
DEFINE VARIABLE dateMonth AS INTEGER NO-UNDO.
DEFINE VARIABLE dateDay AS INTEGER NO-UNDO.
isoDateFormatted = "1980-12-25".
IF NUM-ENTRIES(isoDateFormatted, '-') EQ 3 THEN
ASSIGN
dateYear = INTEGER(ENTRY(1, isoDateFormatted, '-'))
dateMonth = INTEGER(ENTRY(2, isoDateFormatted, '-'))
dateDay = INTEGER(ENTRY(3, isoDateFormatted, '-'))
DATE = DATE(dateMonth, dateDay, dateYear).
MESSAGE isoDateFormatted SKIP
DATE
VIEW-AS ALERT-BOX INFO.
Code:
DEFINE VARIABLE isoDateFormatted AS CHARACTER NO-UNDO.
DEFINE VARIABLE DATE AS DATE NO-UNDO.
DEFINE VARIABLE currentSessionDateFormat AS CHARACTER NO-UNDO.
isoDateFormatted = "1980-12-25".
/** Session Date-format is DMY **/
currentSessionDateFormat = SESSION:DATE-FORMAT.
SESSION:DATE-FORMAT = "ymd":U.
/** IF THE DATE FUNCTIONS ERRORS, THE SESION DATE-FORMAT IS THEN SCREWED. **/
DATE = DATE(isoDateFormatted).
SESSION:DATE-FORMAT = currentSessionDateFormat.
MESSAGE isoDateFormatted SKIP
DATE
VIEW-AS ALERT-BOX INFO.