I need to change the month of specified dates within a dataset. E.g. all March needs to be changed to October, June to November, and August to December. I am using a formula tool to rename the field AdmDate (V_WString) based on the field AdmDateDT (same value but converted from string to datetime format). Example output should be 10/12/2021 for input 03/12/2021.
When I run the below formula tool I get the error: "Parse Error at char(361): Malformed If Statement (Expression #1)" - any ideas what might be causing it?
if DateTimeMonth([AdmDateDT]) == "03"
then "10/" +
DateTimeDay([AdmDateDT]) + "/" +
DateTimeYear([AdmDateDT])
else if DateTimeMonth([AdmDateDT]) == "06"
then "11/" +
DateTimeDay([AdmDateDT]) + "/" +
DateTimeYear([AdmDateDT])
else if DateTimeMonth([AdmDateDT]) == "08"
then "12/" +
DateTimeDay([AdmDateDT]) + "/" +
DateTimeYear([AdmDateDT])
else ""
endif
Solved! Go to Solution.
Hi @aralston
Try changing 'else if' to 'elseif'. If that doesn't work can you attach some sample data?
Would this formula work for you?
IF DateTimeMonth([AdmDateDT]) = 3 THEN
DateTimeAdd([AdmDateDT]), 7, "month")
ELSEIF DateTimeMonth([AdmDateDT]) = 6 THEN
DateTimeAdd([AdmDateDT]), 5, "month")
ELSEIF DateTimeMonth([AdmDateDT]) = 8 THEN
DateTimeAdd([AdmDateDT]), 4, "month")
ELSE
Null()
ENDIF
Chris
That worked, thank you!