Converting 6 Jan 2021 21:19:42 GMT text into a date and time

Certified Lead Developer

What is the best way people have found to convert 6 Jan 2021 21:19:42 GMT text into date and time?

  Discussion posts and replies are publicly visible

Parents
  • f the format will always be consistent, you can create an expression rule to convert your string into a datetime.

    a!localVariables(
      local!months: {
        "Jan",
        "Feb",
        "Mar"
      },
      local!string: "6 Jan 2021 21:19:42 GMT",
      local!date: trim(left(local!string, 11)),
      local!time: totime(trim(right(local!string,12))),
      local!year: right(local!date,4),
      local!day: trim(left(local!date,2)),
      local!month: wherecontains(trim(mid(local!date,3,4)),local!months),
      datetime(local!year,local!month,local!day,hour(local!time),minute(local!time),second(local!time))
    )

Reply
  • f the format will always be consistent, you can create an expression rule to convert your string into a datetime.

    a!localVariables(
      local!months: {
        "Jan",
        "Feb",
        "Mar"
      },
      local!string: "6 Jan 2021 21:19:42 GMT",
      local!date: trim(left(local!string, 11)),
      local!time: totime(trim(right(local!string,12))),
      local!year: right(local!date,4),
      local!day: trim(left(local!date,2)),
      local!month: wherecontains(trim(mid(local!date,3,4)),local!months),
      datetime(local!year,local!month,local!day,hour(local!time),minute(local!time),second(local!time))
    )

Children
No Data