Skip Navigation

[Resolved] This Day in History View – Query by Month/Day only? YEARS_FROM_NOW(int)

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

Last updated by Minesh 3 years, 9 months ago.

Assisted by: Minesh.

Author
Posts
#2036105

Tell us what you are trying to do?
I have a "this day in history" quick bare-bones development setup with a database of dates. I would like to return a view query that displays any events on this date (Month/Day) in the past. I know that the YEARS_FROM_NOW query with a negative integer gets me close but I have some historical references that are back in the 1600's and more that are still being added. I was hoping there might be a hack you guys know of to do this. Ideally something like YEARS_FROM_NOW([any negative value]) - Trying to add in a query with 500 or so filter options seems a bit cumbersome.

Is there a similar example that we can see?
hidden link

What is the link to your site?
hidden link

#2036681

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

Toolset stores the custom date field value as Unix Timestamp and there is no way to compare the date belongs to 1600s using Unit Timestamp as Unit Timestamp date range is not supported to 1600s.

See the heading "Why can UNIX time only represent date-times between 1901 and 2038?" with the following link:
=> hidden link

I would like to know first where you store the date field. Is it a custom field or you want to filter by default post date?

Also, if you stored date value in custom field, is it stored as date string or Unix timestamp?

#2036687

Hey Minesh,

I have the Date set as a Date Custom Field and would like to sort it via the custom field date rather than post date.

I have both the date string and the Unix timestamps in a csv file but for the import into Toolset using WP All Import, it seems it requires the Date String to have a successful import. With that said - Toolset stores it as the Unix timestamp value I believe.

Not sure if there is any workaround to displaying any post in a view that matches month/day or not but that is what I am aiming to do.

#2036701

Minesh
Supporter

Languages: English (English )

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

If you are importing the data to custom date field created using Types, you must make sure that the date value should be imported as Unix Timestamp.

Then, to group posts by month and day, you will require to add some custom code. Please check the following related ticket that may help you to understand how you can achieve this:
=> https://toolset.com/forums/topic/group-results-by-year-and-month-using-date-field/#post-1074869