Skip to content

Dates and template filters #857

@strickon

Description

@strickon

I have a docx template that is applying filters to dates. The dates are expected to be in string format MM-dd-yyyy.

I have a question that is using the date picker. It appears that filters are not being applied to dates.
question: |
Date
fields:

  • Select Date: test_date
    datatype: date

I added the metadata tag to set the default date format

metadata:
date format: "MM-dd-yyyy"

In my template I print the date along with using filters. The only thing that gets printed is the date.

{{test_date}}

{{test_date|filter}}

I know my filters work as if I remove the datatype from the question field and just put the date in as a string , ex 09-05-2025, they all work.

I have also figured out this workaround where I set the date to a temp variable and then use code to format it.

question: |
Date
fields:

  • Select Date: temp_date
    datatype: date

code: |
test_date = temp_date.format('MM-dd-yyyy')

What I don't understand is why simply setting the date format in the meta data doesn't produce the same result?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions