Skip Navigation

[Resolved] how to create a search for a certain range of date?

This support ticket is created 5 years, 2 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)

This topic contains 3 replies, has 2 voices.

Last updated by Nigel 5 years, 2 months ago.

Assisted by: Nigel.

Author
Posts
#1385877
search_view_blog_date.jpg

I am trying to:create a search for a certain range of date, eg eg all posts published in the last 2 weeks? or all posts after 2019/1/1. I have tried "greater than", "smaller than", and "between" with the DATE format, but the result doesn't make sense to me.

Link to a page where the issue can be seen: hidden link

I expected to see: more than 1 posts between the time period

Instead, I got: "no item found" (or 2 posts from 2014 from previous attempt)

I have attached a screenshot of the settings of the search view of the current attempt

#1385981

Nigel
Supporter

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

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

Screenshot 2019-11-18 at 13.55.31.png

Are you trying to filter by the post date, or by a date custom field?

The options for filtering by published date are admittedly not very helpful, unless your reference point is a fixed date, and you would likely need to use some custom code to modify the query.

The options for filtering by a date custom field are a little more helpful.

Date fields are stored as UNIX timestamps, which are numbers (see hidden link).

So the comparison should be as a number.

The screenshot shows an example with a custom field to show posts with field values later than two months ago, with a caveat that this is understood to be the start of the period, so if it is now November then PAST_MONTH x 2 means September, and specifically 1 Sep 2019 00:00:00.

If you can provide details of a specific date filter you'd like to implement I may be able to help.

#1390399

Hi,

Another collegue of yours is helping me, thanks.

#1390899

Nigel
Supporter

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

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

So, this thread can be closed?