Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.
Originally posted by: stonysmithuse
'inputfield'.date("M/D/CCYY").
If you check the help for the date() function, MM requires 2 digits.. M allows either one or two. Same for DD vs D
If your dates are in multiple different formats, you can do something like this:
x=date(null) # no valid date format found
if isDate('inputfield',"CCYYMMDD") then x = 'inputfield'.date("CCYYMMDD")
else if isDate('inputfield',"MMDDCCYY") then x = 'inputfield'.date("MMDDCCYY")
else if isDate('inputfield',"M/D/CCYY") then x = 'inputfield'.date("M/D/CCYY") #handles 1 and 2 digit day and month
else if isDate('inputfield',"M-D-CCYY") then x = 'inputfield'.date("M-D-CCYY")
else if isDate('inputfield',"CCYY/M/D") then x = 'inputfield'.date("CCYY/M/D")
else if isDate('inputfield',"CCYY-m-D") then x = 'inputfield'.date("CCYY-m-D") # lowercase m supports 'Jan','Feb', etc.
else if isDate('inputfield',"D-m-CCYY") then x = 'inputfield'.date("D-m-CCYY")
else if isDate('inputfield',"D m CCYY") then x = 'inputfield'.date("D m CCYY")
emit outputfield = x