Skip to main content
sarahb0004
September 18, 2021
Question

Convert date to a given format then convert to string.

  • September 18, 2021
  • 2 replies
  • 0 views

Hello everyone,

Given any date for example 09182021 in a text format, I need to use it as a variable but change the format to 210918. Is there any way to do it. I'm having troubles finding the right function. Datetext worked fine for me, but I have another task where the date would be provided through rule input and in a text type.

Any help will be appreciated. Thank you.

    2 replies

    stefanhelzle0001
    Brainy
    September 19, 2021

    I think the easiest and most flexible way to turn an unusual date string into a date is by manual parsing using the text functions left(), mid() and right(). Fetch the values for day, month and year from the string and create a new date using the date() function.

    Participating Frequently
    September 19, 2021

    Hi Sarah,

    Assuming the format would not change when day is b/w 1-9 and you are expecting input and output date in text format, i think below approach should do the trick.

    a!localVariables(
    local!inputDate: "09182021",
    right(local!inputDate, 2) & left(local!inputDate, 4)