UrsVinny
3 years agoNew Contributor II
Ternary operation to handle diff date formats
The source file contains Reporting Period value in diff date format.
Aug-2022
Aug-22
AUG 2022
August-2022
I am using the below ternary expression to handle the above mentioned date pattern.
isNaN(Date.parse($RPT_MONTH,‘MMM-yyyy’)) || isNaN(Date.parse($RPT_MONTH,‘MMM-yy’)) ? $RPT_MONTH : Date.parse($RPT_MONTH,‘MMM-yy’).toLocaleDateString({“format”:“MMM yyyy”})
But when the value is in August-2022 the above code is not converting it into AUG 2022
Any kind of help will be highly appreciated.
Cheers
Vinny