How can I format a date from a dynamic expression?

Tabla de contenidos

Athento allows you to apply formatting to dates when evaluating dynamic expressions, such as, for example, when extracting the value of a field at the time of generating a document from a template, etc.

 

To do so, you must use the “strftime” method on a date-type attribute of Athento entities. For example, to apply formatting to a document’s creation date you have to apply the following expression:

fil.creation_date.strftime(<format>)

 

If the dynamic expression for the field extraction is specified, the result will be:

fil.creation_date.strftime('%B %d %Y')

mceclip0.png

 

This can be used in a word template to generate documents with “{{ fil.creation_date.strftime(‘%B %d %Y’) }}“.

 

Valid format codes can be found in the documentation of the Python library.