Date filter selecting the same day in between filter returns no results

Created on 10 January 2017, about 8 years ago
Updated 27 January 2025, about 1 month ago

Problem/Motivation

Steps to reproduce

  • Create a view with an exposed filter of node:created
  • Make just "between" available, and select "date" or "offset" as 'value type'
  • Now chose twice the same day

Expected output

All entries on that day

Actual output

Empty

Proposed resolution

Increase the range automatically by one day, if twice the same day was created

Remaining tasks

User interface changes

API changes

Data model changes

๐Ÿ› Bug report
Status

Needs work

Version

11.0 ๐Ÿ”ฅ

Component

views.module

Created by

๐Ÿ‡ฉ๐Ÿ‡ชGermany dawehner

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands johnv

    The patch still is valid on D11.1

    The problem occurs and is solved in both cases: with Date filter 'date' option and with 'offset' option. Updating summary.
    A test is added, but #20 is still relevant.

  • First commit to issue fork.
  • Pipeline finished with Failed
    18 days ago
    Total: 252s
    #426316
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia niranjan_panem Gurugram

    checked the issue, still exists. Created a patch below is that it contains current timestamp added to offsets to resolve the offset issue.
    โ†’

  • Pipeline finished with Failed
    18 days ago
    Total: 132s
    #426323
  • Pipeline finished with Failed
    18 days ago
    Total: 117s
    #426331
  • Pipeline finished with Failed
    18 days ago
    Total: 97s
    #426334
  • Pipeline finished with Success
    18 days ago
    Total: 817s
    #426342
  • First commit to issue fork.
  • Pipeline finished with Failed
    4 days ago
    Total: 102s
    #438807
  • Pipeline finished with Success
    4 days ago
    Total: 811s
    #438832
  • MR in #28 didnโ€™t fix the actual issue where, if the same date is provided in the filter, it wonโ€™t filter the full day as expected.

    As the problem lies in:

    • For offset type with identical min and max (e.g., +1 day):
      • $a = '***CURRENT_TIME***+86400', $b = '***CURRENT_TIME***+86400'
        

        .

      • Query: $field
        BETWEEN ***CURRENT_TIME***+86400 AND ***CURRENT_TIME***+86400
        

        .

      • Matches only the exact timestamp, not the full day, often yielding no results.
    • For date type, with identical min and max (e.g., 2025-03-03):
      • Both $a and $b will be same 2025-03-03 00:00:00 with no result

    Solution:

    • Offset Type:
      • Add check:
        if ($this->value['min'] === $this->value['max'] && $b_original % 86400 === 0).
        
      • Adjust $b to end of day (offset_days * 86400 + 86399).
      • Retains behavior for offsets with time (e.g., +1 day 4 hours).
    • Date Type:
      • Add check:
        (date('H:i:s', strtotime($this->value['max'])) == '00:00:00').
        
      • Adjust $b to end of the day 23:59:59

    Added test for edge cases mentioned in #20.

Production build 0.71.5 2024