Skip to main content
vijaykumars5676
December 27, 2022
Solved

Text to date conversion

  • December 27, 2022
  • 4 replies
  • 0 views

How do I convert the   "Thu, 10 Nov, 2022"   this text to date?

I am getting this data from IDP in text format.

    Best answer by harshitham3563

    Hi Vijay Kumar, Please look at this code. Hope it will be helpful if the input is in the mentioned format as above.

    a!localVariables(
      local!months: {
        "Jan",
        "Feb",
        "Mar",
        "APR",
        "May",
        "Jun",
        "Jul",
        "Aug",
        "Sep",
        "Oct",
        "Nov",
        "Dec"
      },
      local!splitString: ldrop(
        a!forEach(
          items: split(ri!input, " "),
          expression: substitute(fv!item, ",", "")
        ),
        1
      ),
      date(
        tointeger(local!splitString[3]),
        wherecontains(local!splitString[2], local!months),
        tointeger(local!splitString[1])
      )
    )

    4 replies

    mikes0011
    Brainy
    December 27, 2022

    Off the top of my head I'd guess you will need to build your own Expression Rule to parse the specified text date format you need to consume into a standard Appian Date type object.  If you do some searching in past posts here, i'm guessing you'll find examples that others have built.

    The Expression Guru
    December 28, 2022

    Hi Vijay Kumar, Please look at this code. Hope it will be helpful if the input is in the mentioned format as above.

    a!localVariables(
      local!months: {
        "Jan",
        "Feb",
        "Mar",
        "APR",
        "May",
        "Jun",
        "Jul",
        "Aug",
        "Sep",
        "Oct",
        "Nov",
        "Dec"
      },
      local!splitString: ldrop(
        a!forEach(
          items: split(ri!input, " "),
          expression: substitute(fv!item, ",", "")
        ),
        1
      ),
      date(
        tointeger(local!splitString[3]),
        wherecontains(local!splitString[2], local!months),
        tointeger(local!splitString[1])
      )
    )

    vijaykumars5676
    December 28, 2022

    Thank you so much!!!
    Where do I learn this?

    mikes0011
    Brainy
    December 28, 2022

    My main suggestion for learning stuff like this is to experiment with Appian expression functions and try new things for yourself.

    The Expression Guru