Date formatting / examples of using JSONata expressions
Copy link to clipboard
Copied
Hi there,
I work for SaaS vendor and we are evaluating using Adobe Document Generation APIs.
Is there examples of templates that use date formatting?
What is the syntax for using the date time functions https://docs.jsonata.org/date-time-functions in a template (some examples would be great).
More generally, there are very few examples of using JSONata expressions in templates. It would help greatly if there were more of these.
Thanks
Michael
Copy link to clipboard
Copied
Remember that with the Document Generation Add In, you can quickly test in Word. I did that with the following input,
Now test2: {{ $now() }}
To millis: {{ $toMillis($now()) }}
And saw good results. I didn't test super heavily though. I'd probably consider formatting in code before calling Document Generation to keep the Word template less complex though.
Copy link to clipboard
Copied
Thanks for your reply.
I got the following to work:
Date formatted: {{ $fromMillis($toMillis(Claim.CreationDate), '[D]/[M]/[Y]') }}
Date formatted2: {{ $fromMillis($toMillis(Claim.CreationDate), '[FNn], [D1o] [MNn] [Y]') }}
The syntax is quite verbose as have to convert to/from millis.
I take your point in doing as much formatting as possible in code. As a SaaS vendor with many customers in many different geographies, there are local preferences (date formats, currency, etc) that are sometimes best managed by the templates / templates author as these are unique to customer.
Many thanks for your help,
Michael

