redash icon indicating copy to clipboard operation
redash copied to clipboard

Date time range parameter filter ignore end time

Open javierpelado opened this issue 2 years ago • 6 comments
trafficstars

Issue Summary

Trying to create a query that gets a date and time range filter as a parameter, I noticed that the counter was different than doing it directly within the DB.

The problem is that the filter doesn't use the time at the end threshold. It is filtering out all the records with date time which the date is later than the date end of the range.

It should include in the result the records with the same date and below the time at that threshold.

Example:

  • query using range date and time: image

    After changing the end threshold of the range one minute more what changes the day, all the records from the previous day appear image

Steps to Reproduce

  1. Use the Query results source which will give you sqlite env.
  2. Create a query that filters records using data and time range as a parameter in the form
          select
           createdAt
         from
           cached_query_3
         WHERE
            createdAt BETWEEN '{{ Range.start }}'
            and '{{ Range.end }}'
         order by
             createdAt
    
  3. Fix the end threshold of the range with a time that will include records from the day of it. EG: {day} 23:59
  4. See that in the results there are only records before {day}, none of the records during that day appear.

Technical details:

  • Redash Version: Version: 10.1.0 (2589bef1)
  • Browser/OS: Chrome Version 114.0.5735.198 (Official Build) (arm64) / Macos Ventura 13.4.1 (22F82)
  • How did you install Redash: docker compose in and EC2 instance with external PostgreSQL at AWS Aurora

javierpelado avatar Jul 31 '23 12:07 javierpelado

Oh, that's interesting.

It seems to be truncating the Range variable there to just the date component, ignoring any included time component. That does sound like a bug.

justinclift avatar Jul 31 '23 13:07 justinclift

For date range (with seconds), we should add timezone to fix this bug.

gaecoli avatar Aug 02 '23 03:08 gaecoli

For date range (with seconds), we should add timezone to fix this bug.

And it should add new date format, like hours 23, minutes 59, seconds 59 to format.

gaecoli avatar Aug 02 '23 03:08 gaecoli

@gaecoli Want to try fixing it? :smile:

justinclift avatar Aug 02 '23 06:08 justinclift

@gaecoli Want to try fixing it? 😄

I will try to do it!

gaecoli avatar Aug 02 '23 09:08 gaecoli

@gaecoli / @justinclift Any news on this issue?

antoniocarelli-ancora avatar Jun 11 '24 15:06 antoniocarelli-ancora