Skip Navigation

[Resolved] Filtering a view by date custom field

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

Problem:
Why to use UNSIGNED option with date filters

Solution:
oolset Types stores custom date or date and time field value as a UNIX timestamp. which are positive integers. Therefore, when inserting a query filter to test a date custom field you should use the UNSIGNED option. Please note that the NUMBER option will work for “before” (lower than) and “after” (higher than) comparisons, but not for the “equal to” ones.

You can find proposed solution, in this case, with the following reply:
=> https://toolset.com/forums/topic/filtering-a-view-by-date-custom-field/#post-840962

Relevant Documentation:
https://toolset.com/documentation/user-guides/date-filters/

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

Last updated by thibaultS 6 years, 8 months ago.

Assisted by: Minesh.

Author
Posts
#839310
Capture du 2018-05-07 10-18-54.png
Capture du 2018-05-01 18-11-02.png
Capture du 2018-05-07 09-49-18.png
Capture du 2018-05-07 09-49-51.png

I am trying to:
I have created two custom fields for the post : event_date and report (checkbox). I want to create 2 views. One to display all futurs post (event_date >= today) and a second one for old events with report (event_date < today AND report checkbox checked).

My first view doesn't work -> No item found. If i remove the filter i obtain all the result with the correct sort order.
the code of the view is quite simple :

[wpv-layout-start]
	[wpv-items-found]
	<!-- wpv-loop-start -->
	<h1>[wpml-string context="custom-views"]Prochainement[/wpml-string]</h1>
	<ul class="wpv-loop js-wpv-loop">
		<wpv-loop>
			<li>
				[types field='event_date' style='text' format='j F Y'][/types]
				[wpv-post-link] 
			</li>
		</wpv-loop>
	</ul>
	<!-- wpv-loop-end -->
	[/wpv-items-found]
	[wpv-no-items-found]
		<strong>[wpml-string context="wpv-views"]Aucun événement prévu[/wpml-string]</strong>
	[/wpv-no-items-found]
[wpv-layout-end]

I have made some screenshots of the view configuration (filter and so) and the result (with and without filter). Normaly it must display the last two posts. (i have 4 without the filter what is OK but no one with the filter what is wrong).

The view is displayed on my site on the bottom right box of the front page (i'm using layout).

Regards

#839562

I found it in the forum.

If i use unsigned in place of date or date_time it works. But i don't understand why there's a date and date_time types in the filter if we must use unsigned ?

#840181

My site use WPML and use two languages (french and german).

How can i make to display the posts in french when there is no translation for the post (the event_date and report will remain the same between translations) ?

#840962

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

Well - Actually, Toolset Types stores custom date or date and time field value as a UNIX timestamp. which are positive integers. Therefore, when inserting a query filter to test a date custom field you should use the UNSIGNED option. Please note that the NUMBER option will work for “before” (lower than) and “after” (higher than) comparisons, but not for the “equal to” ones.

More info:
=> https://toolset.com/documentation/user-guides/date-filters/

As per our support policy, we entertain only one question per ticket. This will help other users searching on the forum and help us to write proper resolve ticket summery. So I request you to kindly open a new ticket with your each new question.

Thank you for understanding.

#843926

Thanks for the explanations.