Skip Navigation

[Resolved] A Query filter which checks if today's date is between 2 custom field dates

This support ticket is created 5 years, 11 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 1 reply, has 2 voices.

Last updated by Christian Cox 5 years, 11 months ago.

Assisted by: Christian Cox.

Author
Posts
#1160031

I've been playing around with the between filter options but really stuck and it's giving me a right headache!

A post type "Tasks" has a start date and a finish date custom field.

In a view I need to create an Active Tasks output which will check TODAY() and if today is between (or equal to) the start and finish dates then output that Task.

There's no dropdown option to select a custom field on the between filter dropdown options. Is there another way?

#1160048

Hi, in simple cases you can combine two custom field filters to produce this type of View. Create one query filter for start date, and set it to an UNSIGNED value less than or equal to FUTURE_DAY (1). Then create another filter for end date, and set it to an UNSIGNED value greater than or equal to TODAY. Then for "Relationship to use when querying with multiple fields" choose "AND". This approach works if you can use the "AND" clause for all your custom field filters, and if all events have both a start date and an end date value. Let me know if I've misunderstood your request.