12-26-2023 01:06 PM
I have three different ways date column records can be made available in my excel input file for processing namely YYYYMMDD, YYYY-MM-DD , and MM/DD/YYYYY. This means for any input excel file record, the date column can have one of these three formats. Please my question is how can I format any one of these record into YYYY-MM-DD format?
YYYYMMDD >> format into YYYY-MM-DD
YYYY-MM-DD >> do nothing since it is in the right format
MM/DD/YYYYY >> format into YYYY-MM-DD
Thanks.
Solved! Go to Solution.
12-27-2023 04:06 AM
Hi @omiaye ,
You can try the following expression that uses the logical operator || (OR) :
(Date.parse($Date, "yyyyMMdd") || Date.parse($Date, "dd/MM/yyyy") || Date.parse($Date, "yyyy-MM-dd")).toLocaleDateString({"format":"yyyy-MM-dd"})
BR.
Ivica
12-27-2023 01:50 AM
Hi @omiaye ,
Good day, see expression below. Hope this helps.
$myDate.contains('-') ? $myDate : ( $myDate.contains('/') ? Date.parse($myDate,'MM/dd/yyyy').toLocaleDateString({'format':'yyyy-MM-dd'}) : Date.parse($myDate,'yyyyMMdd').tolocaleDateString({'format': 'yyyy-MM-dd'}) )
Thanks,
EmEm
12-27-2023 04:06 AM
Hi @omiaye ,
You can try the following expression that uses the logical operator || (OR) :
(Date.parse($Date, "yyyyMMdd") || Date.parse($Date, "dd/MM/yyyy") || Date.parse($Date, "yyyy-MM-dd")).toLocaleDateString({"format":"yyyy-MM-dd"})
BR.
Ivica
12-29-2023 01:47 PM
Thanks everyone for your response; it is greatly appreciated.