I have a view in Drupal 8 as below. [The date column in below list, is not an event. its order item. so date showing is order complete date only]

enter image description here

When I filter with start and end date, the data shown excludes the end date. It just shows the in-between records, but it does not include the end date. I am unable to figure it out from the code.

enter image description here

enter image description here

Any help?

  • It's not clear from your screenshot if the Date column in your results is the Start or the End date. – prkos Aug 28 at 18:55

Time also matters (date fields also has time, usually it's set to 0 am). Check in your database what time is associated with the date. If the time is i.e. 11 am or even 00:00:01 am (H.m.s), it will be excluded. It also can be changed the base date by your settings. (i.e. when you create a new date it can be created by default to 0 o'clock and to 12 o'clock too. Or even it can be the node creation time too.

Please note, when you compare date/time most probably the UNIX timestamp will be compared (in views at least)! Reason: drupal save UNIX timestamps into the database, when you create a view you will see the relation is in the query, so the inputed date will be converted to timestamp and a default time. And this default time can be mess up the things.

  • Correct, I observed the end date field value(timestamp value. because it has no hr, min ) is less than order item date timestamp. I was thinking of a way if date can be incremented – dhiraj900 Aug 29 at 10:07
  • For this you have two solutions I think, first when you create the node, you remove the time by setting it to midnight 0, or by adding time to the end date at the backend (until the last second of the day). I guess there's a few alter for that. Or if you don't want to alter, make your own filter plugin (even with extending the already existing one), which will include that time. – golddragon007 Aug 29 at 15:36
  • Thanks, I am php developer and know very less about Drupal. I am having difficulty finding the end date field value (set in view ) in code – dhiraj900 Aug 30 at 1:09
  • I don't know either from my head. Use xdebug or devel module's kint() function. – golddragon007 Aug 30 at 7:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.