0
votes

I have one date field - ddmmyyyy and I want to convert it to date format YYYY-MM-DD T00:00:00. I have tried with as :date and also with local date then date - as: loacaldate as date

2

2 Answers

0
votes

Try this one

%dw 1.0
 %output application/json
 %type mydate = :string { format: "YYYY-MM-DD T00:00:00" }
 ---
{
formatedDate1: |31032016| as :mydate,
}
0
votes

DataWeave Date which is defined between '|' must follow the ISO-8601 standard. Another thing is, I still unable to put a dynamic value on it, e.g.: |payload.origDate|.

For this issue, the following script working properly at my machine:

%dw 1.0
%output application/json
---
{
    formattedDate: (payload.origDate as :date {format: "ddMMyyyy"}) as :string {format: "yyyy-MM-dd'T'00:00:00"}
}

Notes: payload.origDate is a String "31032016"