Using ISO-DATE

Posted by LegacyUser on 25-Jan-2005 03:35

In OpenEdge there is support for creating ISO-formatted date strings using the new ISO-DATE function. However, I can't find any equivalent function for importing date strings from ISO format to a DATE variable.

The DATE(string) function insists that the string is in " the format specified by the Date Format (-d) startup parameter (the default is mdy)."

I want to export/import dates using the ISO date format.

Any suggestions?

All Replies

Posted by jmls on 20-Mar-2012 04:57

so, now I need to do this as well

As it has been 7 years since this post, I was wondering if some new feature / function has snuck into the langauge ...

how can I convert an ISO-Date string back into a datetime or datetime-tz field ?

Yes, I have written conversion method. But it is yukky

Posted by Peter Judge on 20-Mar-2012 07:46

jmls wrote:

so, now I need to do this as well

As it has been 7 years since this post, I was wondering if some new feature / function has snuck into the langauge ...

how can I convert an ISO-Date string back into a datetime or datetime-tz field ?

Yes, I have written conversion method. But it is yukky

Yukkier than this?

    method static public datetime-tz ToABLDateTimeFromISO(input pcValue as character):
        define variable cDateFormat as character no-undo.
       
        cDateFormat = session:date-format.
        session:date-format = 'ymd'.
       
        return datetime-tz(pcValue).
        finally:
            session:date-format = cDateFormat.       
        end finally.
    end method.

-- peter

Posted by jmls on 20-Mar-2012 08:24

meh. from the manual

...

guess I missed the "Typical" and never tried any other format apart from mdy or dmy

Thanks !

Posted by Admin on 20-Mar-2012 08:31

guess I missed the "Typical" and never tried any other format apart from mdy or dmy

 

Another episode from the ABL hidden treasures.

I also learned it from Peter's AutoEdge foundation routines (for OE BPM) and not from the docs. There is some valuable stuff in his code.

Posted by robw@hltool.com on 20-Mar-2012 08:36

Mike I downloaded Autoedge as well, primarily to look for some good oo examples.  We are all of us starved for code examples with Openedge.

...well at least I am.

Posted by Robin.Smith@Fluidthinking.com.au on 21-Mar-2012 19:25

Here is another way but not as efficient but an interesting use of the new JSON tools in OE11

      define variable oJObj as Progress.Json.ObjectModel.JsonObject no-undo.

      oJObj = new Progress.Json.ObjectModel.JsonObject().

      oJObj:Add('date',pcS).

      return oJObj:GetDatetimeTZ('date').

Robin

Posted by Peter Judge on 22-Mar-2012 06:46

Nice!

-- peter

This thread is closed