Legacy Dev Forum Posts

 View Only

Sign Up

  • 1.  Architect String to Date

    Posted 06-05-2025 19:10

    Graeme_Watson | 2019-09-27 15:18:06 UTC | #1

    Hello,

    The Amazon Lex step returns variables that are all of type String.

    In my case one of these variables is actually a date - for example 2019 10 2

    I need to play back this variable as audio but in date format

    I trying the MakeDateTime and ToDateTimebut without any real success.

    Can this be done in Architect?

    Thanks


    MelissaBailey | 2019-09-27 15:39:55 UTC | #2

    ToDateTime requires the value to be in the form YYYY-MM-DDThh:mm:ss[Z|(+|-)hh:mm]. Since your string doesn't look like that, you'll need to do string manipulation to pull out the year, month, day, etc and use the MakeDateTime function.

    For example:

    MakeDateTime(ToInt(Split(Task.originalString, " ")[0]), ToInt(Split(Task.originalString, " ")[1]), ToInt(Split(Task.originalString, " ")[2]))

    You need to be certain of the format of the response; if the value comes back as "2019/10/2" the expression above will cause an error b/c when the string is split by a space there is only one entry. Could you use a lambda with your lex action to force the response into a specific format?


    system | 2019-10-28 15:39:58 UTC | #3

    This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.


    This post was migrated from the old Developer Forum.

    ref: 6127