Skip Navigation

[Resolved] Legacy View – Query Filter for custom field date not working

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

Problem:

Which type should I use to compare dates?

Solution:

Use the number as dates are saved as UNIX timestamps in the database.

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.

This topic contains 5 replies, has 2 voices.

Last updated by Timothy 1 year, 10 months ago.

Assisted by: Christopher Amirian.

Author
Posts
#2543119

I have a cpt with a custom date field "Last Date Reviewed". I'm trying to display posts (actually just the number of posts, using [wpv-found-count] ) that have this date set to within 2 months of today. In the query filter I've tried all sorts of options including: "The field Last Review Date is a " + "Date" + "greater than" + "PAST_DAY" + "30" but nothing seems to work.

I think I read in other threads that the date query filter is a bit wonky... any other options I have to do this?

Tim

#2543125

Actually this seems to work is I select "Signed" rather than Date. This seems odd... what does Signed and Unsigned mean? Is this the expected behavior?

Tim

#2543721

Christopher Amirian
Supporter

Languages: English (English )

Hi Tim,

This is not intuitive, but, because of the way that Types date fields are stored in the database—as Unix timestamps—the field is not a DATE or a DATETIME, it is a NUMBER.

TODAY() is converted to a Unix timestamp, e.g. today 31-01-2017 will be converted to 1485820800, and, likewise, the values of your custom field dates are stored as Unix timestamps, so you are actually comparing numbers.

That is why SIGNED works.

Thanks.

#2543755

Thanks for the explanation. So then "Number" should work as well as "Signed" right?

And I'm pretty sure this confusion has existed for years at this point. Any plans to make this more intuitive?

When I keep coming across issues from older threads that expose issues that have existed for years and years it really makes me worry about the future of the Toolset plugins. And the last thing I want is for these plugins to sunset... I have dozens of sites using Toolset.

Tim

#2544237

Christopher Amirian
Supporter

Languages: English (English )

Hi there,

Yes, the number should do the trick.

I am sure you have experience so I do not want to diminish that. Just about this specific case, it is how the system is implemented and actually, it is the best system to have a date comparison.

It is a pretty standard way to convert dates to UNIX timestamps to compare and Toolset already saves the date in UNIX timestamp which gets things easier.

Don't worry we are not going anywhere and you have our full support of us as the technical support here if you encounter issues. We either report to the developers if there is an issue to fix or provide a workaround.

Thanks.

#2544279

My issue is resolved now. Thank you!