Convert a datetime Text to DateTime object

Certified Lead Developer

Hi, 

Is there an OOTB function to convert a datetime text to DateTime object?

The datetime string is of the format - YYYY-MM-DDThh:mm:ss.SSSZ (Example: 2018-07-20T09:09:26.000Z)

 

TIA

Regards,

Sunil Zacharia

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    In the past I needed to do a much similar conversion - here's the expression rule I used:

    with(
      local!dateTimeValueArray: split(substitute(substitute(substitute( ri!string,  " ", ":" ), "-", ":"), ".", ":"), ":"),
      if(
        rule!APN_isEmpty(local!dateTimeValueArray),
        null(),
        datetime(
          local!dateTimeValueArray[1],
          local!dateTimeValueArray[2],
          local!dateTimeValueArray[3],
          index(local!dateTimeValueArray, 4, 0),
          index(local!dateTimeValueArray, 5, 0),
          index(local!dateTimeValueArray, 6, 0),
          index(local!dateTimeValueArray, 7, 0)
        )
      )
    )
Reply
  • 0
    Certified Lead Developer

    In the past I needed to do a much similar conversion - here's the expression rule I used:

    with(
      local!dateTimeValueArray: split(substitute(substitute(substitute( ri!string,  " ", ":" ), "-", ":"), ".", ":"), ":"),
      if(
        rule!APN_isEmpty(local!dateTimeValueArray),
        null(),
        datetime(
          local!dateTimeValueArray[1],
          local!dateTimeValueArray[2],
          local!dateTimeValueArray[3],
          index(local!dateTimeValueArray, 4, 0),
          index(local!dateTimeValueArray, 5, 0),
          index(local!dateTimeValueArray, 6, 0),
          index(local!dateTimeValueArray, 7, 0)
        )
      )
    )
Children