Dates in Drupal views

I created a Drupal view that sort data based on “arrival date” : it is suppose to show information if the arrival_date is bigger or equal to a fixed date (that can be entered by the user):
in the query I have :
((DATE_FORMAT(node__field_visitor_from_date.field_visitor_from_date_value, ‘%Y-%m-%d’) >= DATE_FORMAT(‘2023-01-01T01:00:00’, ‘%Y-%m-%d’)))
but the result give me data whose arrival date is the day after the one entered
I suspect it is due to the “time” but I do not know how to remove it
In the configuration of the sort criteria I added “granularity” = day but even if I put second it does not change …
Any suggestion ?

Hi Elena,

I am a bit confused: you say it retrieves dates AFTER the one manually entered - but you have set it to greater than or equal to a particular date - that’s exactly the desired behaviour, no?

Or have I misunderstood?

If you’re sure it’s about the ‘time’, then maybe look at how you set the date format. Did you set the date format for that field at /admin/config/regional/date-time, or did you do an override directly into the view field?

If you did a local override in the view, then maybe you could try creating that format via /admin/config/regional/date-time instead, and then selecting it as a date format within your view.

Without seeing your view set-up or knowing how much compromise is possible, it’s quite hard to debug :slight_smile: but in my experience, incorrect date filters have usually stemmed from me putting the incorrect view filters on (eg a wrong operator, or incorrect date parameters).

Incidentally, the sort function doesn’t play much of a role here, it’s really the view filter criteria

Let us know how you get on…


By the way, I just tried to replicate your view according to your description; this is what I have set up, and it works fine:

And this is the result (which is arrival date same as or greater than inputted value):

Hope that helps.


Dear Catherine
thanks a lot for your help ! indeed I found my error that is coming from the import of the content. I have to understand why, but indeed the view is working as it should … :slight_smile: