Skip Navigation

[Resolved] Date filter query not working

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

Problem:
How to filter posts to only show posts with a date field set to tomorrow?

Solution:
Date fields are saved as timestamps (the number of seconds since 1970) and so the filter needs to compare the field as a number, which in this case should be equal to FUTURE_DAY of 1, i.e. one day forward, or tomorrow.

Relevant Documentation:
https://toolset.com/documentation/user-guides/filtering-views-by-custom-fields/

This support ticket is created 5 years, 7 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 18 replies, has 2 voices.

Last updated by leilaG 5 years, 6 months ago.

Assisted by: Nigel.

Author
Posts
#1271783

Nigel
Supporter

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

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

The post we are testing against (Bob Jones) has an entry in wp_postmeta for wpcf-arrival-date = 1560902400.

Using epochconverter.com we can see this translates to 19 June 2019 00:00:00 (i.e. "tomorrow").

You've updated the View filter to FUTURE_DAY(2), which from the debug info translates into testing if wpcf-arrival-date = 1560988800.

Using epochconverter.com we can see this translates to 20 June 2019 00:00:00 (i.e. the day after tomorrow).

Hence the View is returning no result.

Everything here looks as expected.

#1271789

Okay, but there is a visitor (Rebecca Long) that has arrival date 20 June 2019, but she doesn't show up in the results

#1271797

Nigel
Supporter

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

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

Screenshot 2019-06-18 at 16.27.41.png

But she's in Glasgow, and your View has a filter for Nottingham.

#1272371

Oh yes ofcourse!! Looks like it's working well now. Thank you!