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
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
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.
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
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.
My issue is resolved now. Thank you!