Have your say in Community Polls: What was/is your greatest motivation to start your own business?

Re: Question about date comparison

How to properly compare dates for unfulfilled orders older than 3 days?

scamby
Tourist
7 0 2

We are running a modified version of the "Send Email Summary With All Unfulfilled Orders Older Than 2 Days" template on all our shops.  I had originally used this for my order query (thanks to DaveMcV for the help) -

 

created_at:<='{{ scheduledAt }}' AND created_at:>'{{ scheduledAt | date_minus: "3 days" }}' AND financial_status:paid AND fulfillment_status:unfulfilled AND test:0 AND closed:0 AND cancelled:0

 

But we noticed it was returning orders that were created within the last 3 days.  I recognized that using scheduledAt was the issue.  I thought that was the date the instance of the schedule was ran when in actuality, it was the date the schedule began.  So I then switched to this query -

 

created_at:<='{{ 'now' }}' AND created_at:>'{{ 'now' | date_minus: "3 days" }}' AND financial_status:paid AND fulfillment_status:unfulfilled AND test:0 AND closed:0 AND cancelled:0

 

But it still isn't returning the correct orders.  I want to return any orders that were created at least 3 days ago but how do I do the comparison of created_at to today's date (the date this iteration of the schedule is running) to get the correct orders?

Reply 1 (1)

FePixie
Shopify Partner
30 2 7

maybe try something like

{% assign today_date = 'now' | date: "%Y-%m-%d"%}

then

created_at:<='{{ today_date }}'...