0

I am using Solspace's Date Field Filter to group sales on a site. I need to display everything from yesterday (relative to current date) and older. I also need to do this moving forward (forecasting), so tomorrow (relative to current date). All of the dates being checked are custom date fields in EE's native date fieldtype though.

So instead of something like this:

{exp:channel:entries
    date_field="{sale_dates_and_times:date}"
    date_field_start="{current_time format='%Y-%m-%d %h:%i %A'}"
    channel="sales"
    limit="5"
    orderby="{sale_dates_and_times:date}"
    sort="desc"
    paginate="bottom"
    dynamic="no"
}

I would need the date_field_start to be yesterday or tomorrow.

Is there a way to do this easily? I think I am making this harder on myself than it needs to be.

Thanks

****UPDATE****

So I have the date coming in like I need it now, but I am not receiving filtered results...

I used the DT Plugin, thanks to Sam for pointing that out, to get the dates needed. I verified the dates by rendering them out. Since it didn't work, I even tried to use Stash to pass that into the channel entries tag. Still no good. Is there something I am doing wrong Solspace? My date field is in a grid like this:

Grid Field = {sale_dates_and_times}

Sub Fields = date | opening_time | closing_time or

{sale_dates_and_times:date} {sale_dates_and_times:opening_time} {sale_dates_and_times:closing_time}

I have this now:

{exp:stash:set name="previous"}{exp:dt day='-3' format='%Y-%m-%d %h:%i %A'}{/exp:stash:set}

This renders as 2015-09-11 12:57 PM

{exp:channel:entries
    date_field="{sale_dates_and_times:date}"
    date_field_start="{exp:stash:get name='previous'}"
    channel='sale'
    limit='5'
    orderby="{sale_dates_and_times:date}"
    sort="asc"
    paginate="bottom"
    dynamic="no"
}

In my test I should just see 1 entry since there is one set to a previous date range, one set to current date ranges, and one set for a future date range. However, I am getting all entries returned.

These are with the following dates:

Entry-1:

Friday 09-11-2015 — 9:00am-9:00am
Saturday 09-12-2015 — 9:00am-9:00am
Sunday 09-13-2015 — 8:00am-8:00am

Entry-2:

Tuesday 09-01-2015 — 9:00am-9:00am
Wednesday 09-02-2015 — 9:00am-9:00am
Thursday 09-03-2015 — 8:00am-8:00am

Entry-3:

Friday 09-25-2015 — 9:00am-9:00am
Saturday 09-26-2015 — 9:00am-9:00am
Sunday 09-27-2015 — 8:00am-8:00am

Why would all three be rendering in this case?

Thanks

0

If you have the Calendar module installed, you could use the {exp:calendar:date} tag to calculate yesterday's date: https://solspace.com/docs/calendar/date/

You might need to put your code in an embed and pass the result of {exp:calendar:date} in this embed, since in EE you can't put {exp:...} tags inside another {exp:...} tag's parameter (even if someone says they managed to pull that off, it's not recommended ;)).

| improve this answer | |
  • I looked at that, but that is WAY too much overkill for this. I just need to show future and past. That seems like a small task for a heavy load payoff. – W3bGuy Sep 11 '15 at 17:39
  • I updated my OP with results using proper date. Still not getting filtered results. ??? – W3bGuy Sep 11 '15 at 18:32
  • 1
    Are you trying to use Date Field Filter in a Grid field? If so, Date Field Filter is not compatible with Grid fields. Date Field Filter works with... (native EE) Date Fields. Also, turning Template Debugging in EE will save you a lot of time checking if variables in parameters are parsed before {exp:...} tags. You can check if your Stash or other 3rd-party add-on tag is parsed before {exp:channel:entries} is. – Solspace Sep 14 '15 at 11:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.