This help desk is no longer actively support. We have switched to a ticketing system to more smoothly manage support, and free up development time. Your newly created tickets won't be available here. You will instead have an email history of your new tickets.

We are working on moving everything current and helpful from public tickets into the docs. This will be a long process and in the meantime, public tickets will remain searchable.

Your private tickets will remain available to you indefinitely. See your old tickets.

Help Desk

How to filter entries by combined date and time field

Labels

This Ticket is public

Notifications

Hi ,

We are working on food related platform. On this platform some users can post listings and others can book. Users who offer meals can define a limit date time, after which this listing should not be available. On our form side, date and time are two separate fields, we tried combining them into a "combined date and time" field. The combined format is standard: 2000-01-01 00:00:00

The on the listing view, we set a filter for the combined date and time field that should be lower or equal to now. But the filtering only work for the date, not the time. Meaning that listings won't show after date has passed, but not after time has passed.

 

Ideally if the used has set that limit time is Dec 5 at 8.30pm, the listing should not show anymore after 8.31pm.

Is there any way to achieve that?

Thank you.

 

Hello,

The best way to go about this in my opinion would be to convert the date/time string to EPOCH format, which will save the date/time in seconds after January 1, 1970.

That would require custom code, but would be effective.

Would that work for you?

Hi, thank you. I will try and let you know.

Hi, I tried changing manually the combined time and date of a few entries with EPOCH time stamps. But it doesn't seem to filter after the time has passed. Would it be possible to know exactly which time format is used in the php to filter the data?

 

Thank you.

Hi,

Actually I found out that no matter which format the filtering never worked for my combined time and date field. It seems that filtering with the value "NOW" or "1 day, 1 hour..." only work if the compared field is set up as a date field. Since my combined time and date field is a simple text field it doesn't work. But if I switch the type of field to date, the validation makes it impossible to submit the form. Is there a simple way to deactivate form validation for one date field only?

 

Thank you.

Ghislain.

Hi,

Sorry for the delayed reply.

Instead of using NOW as a filter, set up the filter like this:

'Expiry Date and Time' is greater than [date format="Y-m-d"] [time format="H:i:s"]

Where Expiry Date and Time is the date and time the user selected in the form, saved in either a single line text field or a hidden field, in the date format Y-m-d and time format H:i:s.

Does that work for you? Any questions about this?

Wow, thank you so much. I didn't think it would work but it does! Perfectly.

Thanks.

I'm glad it worked out for you!

Hi,

I'm sorry to reopen this ticket but I thought it would give some context to whoever takes on this case.

We are now working on the user account side, and we need to display the listings that are expired within the last two weeks. We are using the same consolidated time field, but it doesn't work when compared with "+2 weeks" nor "+14 day". Is there a way to adjust this: [date format="Y-m-d"] [time format="H:i:s"] to add 2 week to the "date".

Thank you.
Ghislain.

Hi Ghislain,

Your new question isn’t quite the same as the original question in this ticket, and this ticket is quite old and already long. Can you please open a new ticket instead? This helps our team respond more quickly when we don’t need to review the whole conversation before responding.

Thank you!

Ticket closed.