cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Date conversion

Harsha3
New Contributor III

Hi ,

I am having a source csv file which contains the date in the format dd-MON-yyyy ( say for example 01-JAN-2020 ) . I need to convert this data format to the form yyyy-mm-dd ( say 2020-01-01 ) . I have tried using various methods to parse the date but could not achieve the conversion . So I have used the conditional mapping here and the code gets bigger as I need to incorporate 12 months and hard code the values . Please refer below

$Review_Date.split(โ€˜-โ€™)[2]+โ€˜-โ€™+$Review_Date.split(โ€˜-โ€™)[1]==โ€˜Janโ€™?โ€˜01โ€™:($Review_Date.split(โ€˜-โ€™)[1]==โ€˜Febโ€™?โ€˜02โ€™:โ€˜00โ€™)+โ€˜-โ€™+$Review_Date.split(โ€˜-โ€™)[0]โ€ฆโ€ฆ

Is there any optimised way in achieving the above scenario .

3 REPLIES 3

jovan_j
New Contributor III

Hi Harsha3

Can you please check if the following expression resolves your query?
image
Date.parse(โ€œ01-JAN-2020โ€, โ€œdd-MMM-yyyyโ€)

You can place the โ€œ01-JAN-2020โ€ with any value from input as following:
Date.parse($Review_Date, โ€œdd-MMM-yyyyโ€)

Regards, Jovan.

Harsha3
New Contributor III

Hi Jovan,

Excellent it worked . Cheers!

sdeng
New Contributor II

What if โ€œ01-Jan-2020โ€, how do I put the mask?