Skip to main content
Question

Jinja2 Expressions for date quarter

  • January 10, 2023
  • 0 replies
  • 444 views

For my pipeline file output name I'm trying to format an output report filename field based on a specific date in Jinja2. Based on that date the naming convention should include which quarter the data contains.  

ex. Report Date = 12/31/22

Desired outputfile name =  Report_(#QYY)_<MM-DD-YYYY> eg. Report_Q422_01-10-2022

How can I manipulate the date to return a number for the quarter ?



------------------------------
Jerome Mitchell
------------------------------
This topic has been closed for replies.

Forum|alt.badge.img+6
  • Quickbase Staff
  • January 10, 2023
This Jinja should format the report title (replace reportDate with your field name):
NOTE: Edited to fix quarter formula
{% set reportDate = time.now - time.delta(months=1) -%}
{% set year = reportDate.strftime('%y') -%}
{% set qtr = (reportDate.month/3) | round(method='ceil') | int %}
{{ "Report_Q%s%s_%s" | format(qtr, year, reportDate|date_mdy) }}​

------------------------------
Doug Henning
------------------------------