0
votes

I am performing a CSV to CSV transformation using DataWeave.

One of the Input fields is a string 13/01/2015. My requirement is to convert this string to a date format as 13-Jan-2015.

I have tried using as :string{"dd/MMM/yyyy} and as :date{format:dd/M/yyyy} functions but did not succeed in changing the format.

Here is what I tried:

payload map { 
  "Order Number":$[0],
  "Order Date": ($[1] as :date{format:"d/M/yyyy"}),
}

This conversion gave the output as

Order Number,Order Date
14710655,2015-08-17 

Then I tried the following:

 payload map {
    "Order Number":$[0],
    "Order Date": ($[1] as :date{format:"d/M/yyyy"}) as :string{format:"d/MMM/yyyy"})
 }

This conversion gave the output as

Order Number,Order Date
14710655,17/8/2015   
1
Please provide the relevant code. - Mr Mush
added code to the question - keerthi ch
Have you already looked at the documentation? - Burhan Khalid
I just tried with the last alternative you mentioned and it gave 13/Jan/2015 as expected, what mule version are you using? - Shoki
i have gone through the documentation @BurhanKhalid - keerthi ch

1 Answers

0
votes

When I tried :string { format: "dd-MMM-YYYY"}, it gave me 13-Jan-2015.