Skip Navigation

[Resolved] Filter posts between two dates

This thread is resolved. Here is a description of the problem and solution.

Problem:
How to add a filter to only display posts between two dates (a backend filter).

Solution:
You need to insert two Query Filters in your View, one for each field.

You would specify that the start date should be less than TODAY(), and the end date is greater than TODAY().

Note that dates in filters are treated as numbers, and in the example we use the UNSIGNED number type.

Relevant Documentation:
https://toolset.com/documentation/user-guides/date-filters/

This support ticket is created 6 years, 5 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

Tagged: 

This topic contains 4 replies, has 2 voices.

Last updated by jackO 6 years, 5 months ago.

Assisted by: Nigel.

Author
Posts
#911621
datetime.PNG

Hi there....

I've made a view named promotion. It will display a post based on their date and time. It has Promote Start Date and Promote End Date. The datetime.png is an example of date time that I'm insert on field...

So, I want to filter a post that will display between promote start and promote end...

How can I filter it?

#911671

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi there

This depends slightly on what you want to do.

Do you want to have a permanent filter that displays matching posts where, today, they are between the start and end dates.

Or do you want front-end filter controls where the user sets a start and end date and you display posts according to whether their start date is later than the chosen start date and end date is before the chosen end date, for example? Or something similar but that interprets the dates differently?

If you can let me know how the dates should be filtered I can help set it up.

#911766

I want to display the post between promote start and promote end. That's means it will display if today is between start and end. The promote start and promote end dates will insert in other form. So, if today is after the start date and before end date, it will promote.... If before start or after end, it didn't displayed the form...

It will filter on View (back end)... don't have filter control on front end...

#911801

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Screen Shot 2018-06-11 at 13.35.34.png

In that case you need to insert two Query Filters in your View, one for each field.

You would specify that the start date should be less than TODAY(), and the end date is greater than TODAY().

See the documentation here: https://toolset.com/documentation/user-guides/date-filters/

Note that dates in filters are treated as numbers, and in the example we use the UNSIGNED number type.

#912141

Ok... It's worked... Thanks, Nigel...