Shopify Flow is an ecommerce automation platform that enables you to automate tasks and processes within your store and across your apps.
We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more
I want to dynamically set the datetime in the created_at filter to the current month's first day and last day in the flow. currently, the information is hard-coded.
Here's my shopify flow:
In the Get Order Data Action, here's the script of in advanced query:
{{order.customer.id}}
AND created_at:>=2025-06-01T00:00:00Z
AND created_at:<=2025-06-30T23:59:59Z
Is there a way to dynamically change the value when next month comes? I can't manually set the value in the flow every month even if I make a scheduled reminder. Manually changing is OPTION 1.
OPTION 2: My other idea is to create a backend (hosted in AWS) that can run once a month that updates the the order's metafield like first_day_of_the_month and last_day_of_the_month.
The backend app will call a graphQL mutation to update. here's the flow:
1. the backend app accepts customer ID or all order will be updated
2. Get all orders as we need the order ID to use in the graphql to update its metafield
3. Update the metafields using mutation
Or is there a simpler way to do it?
Solved! Go to the solution
This is an accepted solution.
Yep, Shopify Flow has date-filters specifically to handle stuff like this.
{% assign first_day = "now" | date: "%Y-%m-01T00:00:00Z" %}
{% assign last_day = first_day | date_plus: "1 month" | date_minus: "1 second" %}
{{order.customer.id}}
AND created_at:>={{ first_day }}
AND created_at:<={{ last_day }}
Should do the trick nicely.
Running a testflow in my own store the query looks like this with the above filter:
{
"field_name": "orders",
"api_version": "2024-07",
"query_args": {
"sortKey": "CREATED_AT",
"reverse": false,
"query": "\n\n\ngid://shopify/Customer/8495132475578\nAND created_at:>=2025-06-01T00:00:00Z\nAND created_at:<=2025-06-30T23:59:59Z"
},
"max_root_records": 10
}
More info here: https://help.shopify.com/en/manual/shopify-flow/concepts/variables#filters
This is an accepted solution.
Yep, Shopify Flow has date-filters specifically to handle stuff like this.
{% assign first_day = "now" | date: "%Y-%m-01T00:00:00Z" %}
{% assign last_day = first_day | date_plus: "1 month" | date_minus: "1 second" %}
{{order.customer.id}}
AND created_at:>={{ first_day }}
AND created_at:<={{ last_day }}
Should do the trick nicely.
Running a testflow in my own store the query looks like this with the above filter:
{
"field_name": "orders",
"api_version": "2024-07",
"query_args": {
"sortKey": "CREATED_AT",
"reverse": false,
"query": "\n\n\ngid://shopify/Customer/8495132475578\nAND created_at:>=2025-06-01T00:00:00Z\nAND created_at:<=2025-06-30T23:59:59Z"
},
"max_root_records": 10
}
More info here: https://help.shopify.com/en/manual/shopify-flow/concepts/variables#filters