question

RevathiSubramaniam-9608 avatar image
0 Votes"
RevathiSubramaniam-9608 asked ·

Need DateTime format in Liquid template

Hi,

I need to convert datetime format as "yyyy-MM-dd'T'HH:mm:ss.fff'Z'" from this date format "2020-09-14T12:00:00+0000.

But when i convert in liquid template from json to json using this "yyyy-MM-dd'T'HH:mm:ss.fff'Z'" syntax. am always getting 2019-01-01T12:00:00Z this one as output always.Here milliseconds is not coming. i need to get ouput like this 2019-01-01T12:00:00.000Z.

could anyone help on this please

azure-logic-apps
· 2
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @RevathiSubramaniam-9608

Following up to see if my answer helps. Do let me know if you any queries.

0 Votes 0 ·

Hi @RevathiSubramaniam-9608

I hope the answer helps. Please let me know if you any further queries.

0 Votes 0 ·
MayankBargali-MSFT avatar image
0 Votes"
MayankBargali-MSFT answered ·

Hi @RevathiSubramaniam-9608

I don't see a way to achieve it using a liquid template. Logic app liquid leverages the opensource dotliquid where you can also contribute. Looking into the source code I don't see a way to achieve your result using DotLiquid as it is a limitation from their end.

Alternately, to convert the string to your desire format you can try to use inline code by writing your own code to achieve the desired result.

Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community looking for help on similar topics.

·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

RakeshKhanna avatar image
0 Votes"
RakeshKhanna answered ·

If you look at the source code for dotliquid it does formats the date with code DateTime.ToString(format). this format takes in the string and you can provide the desired format as in normal .net class. Just add

 "desiredDate": "{
                 {DesiredDate | date:"yyyy-MM-dd HH:mm:ss.fffZ"}}",`  

and it will give you the milliseconds in results.


·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.