This post has bas been made on behalf of a user who posted the following question on the (now retired) Lavastorm Forums:
Need help on this date reformat. I have a data that have a date&time in the format below but I've tried to reformat it to "MMDDCCYY"
"Thu Mar 12 00:00:03 2020"
Assuming your input datetime string is in a field named 'testDate' you could use the following script in a Filter node:
## Trim any leading and trailing whitespace chars
dt = testDate.trim()
## Split the string on the space chars
dt_elements = dt.split(" ")
## Construct a new string containing only the required date elements
dateStr = dt_elements + " " + dt_elements + " " + dt_elements
## Convert the new string to a Date type
dateValue = date(dateStr, "m D CCYY")
## Define the formatted date string
outDateStr = pad(str(month(dateValue)), 2, "0" ) +
pad(str(day(dateValue)), 2, "0" ) +
emit outDateStr as "outDate"
Please sign in to leave a comment.