Skip Navigation

[Resolved] Using filter in a view with dates

This support ticket is created 2 years, 1 month 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 4 replies, has 2 voices.

Last updated by Miguel 2 years, 1 month ago.

Assisted by: Minesh.

Author
Posts
#2529567
3- with string filter.png
2-with date filter.png
1-without filter.png

Tell us what you are trying to do?
I created 2 custom post types with toolset: Courses and Dates

They have a Relationship One-to-many (Courses-to-Dates). One course would have many dates

Dates have a date custom field called Starting date

I created a template for Courses where I show all the Course info. Below it I wanted to show the next dates (from Dates cpt).

I can list all dates perfectly. Past and future dates are showing.

I wanted to show ONLY future dates, so I added a filter to this view with these conditions: Starting date is a DATE greater than TODAY()

In the design view (backend of template), I can see only the one of future dates, but the following message:

There were no posts found to display for this View's query.

I found that if I use STRING instead of DATE in the filter, it works perfectly.

Starting date is a STRING greater than TODAY()

This is a solution I know, but I was wondering why the filter doesn’t work using DATE.

Is there any documentation that you are following?
https://toolset.com/course-lesson/filtering-toolset-views-by-dates/

Is there a similar example that we can see?
Not really

What is the link to your site?
It's a Local site

#2530159

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Toolset date custom field value is stored as Unix Timestamp in the database. So the correct data type you should use with your filter is "number" instead of "string".

What if you set the "number" with your date custom field query filter - does that works?

#2530631

Minesh, thank you for your detailed explanation!

I tried setting as a number the custom field query filter and it worked too, thanks!

#2530737

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Glad to know that solution I shared help you to resolve your issue. Can you please mark this ticket as resolved.

#2531041

My issue is resolved now. Thank you!