Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Date formatting / examples of using JSONata expressions

New Here ,
Oct 12, 2022 Oct 12, 2022

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

1.7K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Oct 12, 2022 Oct 12, 2022

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.

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 12, 2022 Oct 12, 2022
LATEST

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  

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources