Forum Academy Marketplace Showcase Pricing Features

Date comparison in search filters rounded down to date

Hi,

I want to do a date comparison while doing a “search for”.

While storing the date I am storing like this:
start_date = dateinput rounded down to date

While doing the search I am putting condition like this:
start_date <= dateinput rounded down to date

But this is not working as intended. Criteria is not being satisfied while it should.

What is right way of doing this?

I am aware of the method of “changes hours to 23, change minutes to 59…” method, but that is somewhat less reliable I think as it doesn’t take care of the last second of the day, and it is also bit longer.

Thanks,
Mukesh

If your search is to find data that has a start date that is either equal to the saved date or after it then you need to use greater than or equal to. Other than that I would recommend not rounding the saved date but do round the search filter date.

Thanks for the reply.

The operator “less than equal to” is not a problem. I want to search the data that has start date earlier than or equal to the date that has been entered now.

How does rounding off of saved date make a difference? In fact it is correct I thought as I don’t want the hours and minutes to be considered at all in the comparison. So if both get rounded off, the comparison would be purely on the date, isn’t it?