<@ULVA73B9P> is there a way to pass in an automati...
# ask-marvin
f
@Marvin is there a way to pass in an automation action the current formatted date (something like now.strftime('%Y-%m-%d')) as deployment parameter with jinja templating syntax?
m
Using Jinja templating to pass the current date as a deployment parameter in a Prefect 2.x automation is possible. Jinja templates in Prefect allow you to access properties of the underlying flow run objects, which means you can leverage this functionality to reference dynamic variables such as timestamps. While the information provided from the search isn't explicit about formatting dates with Jinja within a Prefect context, Jinja itself allows for string manipulation and date formatting. In standard Jinja usage, you could use something like
{{ '%Y-%m-%d' | now }}
to obtain the current date formatted as
YYYY-MM-DD
. However, it is important to note that this exact syntax may differ based on the Prefect context and what variables and filters are available within Prefect’s implementation of Jinja templating. From the information provided, Prefect's documentation may not clearly explain how to directly format the current date using Jinja templating. Given the incomplete information from the search, the best course of action would be to consult the most up-to-date Prefect 2.x automations documentation (where possible, the specific doc can be found here) or to test within the Prefect environment to see how you can use Jinja to pass the current date as a formatted string. Keep in mind that the compatibility and availability of Jinja filters for the current date may vary, and you might need to create custom logic within your flow to format and pass the date as a parameter.
f
Copy code
"Failed to render template due to the following error: TemplateAssertionError(\"No filter named 'now'.\")\nTemplate source:\n{{ '%Y-%m-%d' | now }}"
do not works