Skip to main content
sarahb0004
September 8, 2021
Solved

Parse a string from a file name and convert to date.

  • September 8, 2021
  • 2 replies
  • 0 views

Hello everyone,

Given that I have a file name "Test_210908" is there a way for me to get "210908" then convert it to a date 09/08/2021?

Any help will be highly appreciated. Thank you.

    Best answer by gayathris111098

    Hi

    I quickly created this

    a!localVariables(
      local!fileName: "Test_210908",
      local!splitDate: index(split(local!fileName, "_"), 2, null()),
      local!year: left(local!splitDate, "2"),
      local!month: mid(local!splitDate, 3, 2),
      local!day: right(local!splitDate, "2"),
      date(local!year, local!month, local!day)
    )

    2 replies

    gayathris111098
    September 8, 2021

    Hi

    I quickly created this

    a!localVariables(
      local!fileName: "Test_210908",
      local!splitDate: index(split(local!fileName, "_"), 2, null()),
      local!year: left(local!splitDate, "2"),
      local!month: mid(local!splitDate, 3, 2),
      local!day: right(local!splitDate, "2"),
      date(local!year, local!month, local!day)
    )

    sarahb0004
    September 8, 2021

    Wow! It actually worked. Thanks for this. [emoticon:6d505171faa4497c85c5ca27290c555d]