GitHub user dosubot[bot] added a comment to the discussion: Date Filter

<!-- Answer -->
The date filter's inclusivity/exclusivity is hardcoded in two main places:

- Frontend: In 
superset-frontend/src/explore/components/controls/DateFilterControl/components/AdvancedFrame.tsx,
 the UI labels and tooltips explicitly state "Start (inclusive)" and "End 
(exclusive)" and manage the date range as "since" and "until" values. You'd 
need to update these labels and tooltips if you change the logic elsewhere.  
  [See code 
reference](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/src/explore/components/controls/DateFilterControl/components/AdvancedFrame.tsx#L24-L85)

- Backend: In superset/utils/date_parser.py, the get_since_until function 
parses and normalizes the "since" and "until" values. By default, it produces 
ranges that are inclusive for the start and exclusive for the end, using 
expressions like DATETRUNC and DATEADD to define the end as the start of the 
next unit.  
  [See code 
reference](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/utils/date_parser.py#L314-L529)

To make both endpoints inclusive, you would need to:
1. Update the frontend labels/tooltips to reflect the new behavior.
2. Change the backend logic so that the SQL filter uses <= for the end date, or 
adjust the "until" value to include the full end date (for example, by adding 
one day for day-level granularity, or one microsecond for timestamp-level).

Be aware that this change can have side effects, especially with time 
granularity and timezone handling, so review any dashboards or queries that 
rely on the current [inclusive, exclusive) behavior.


<!-- Dosu Comment Footer -->
*To reply, just mention [@dosu](https://go.dosu.dev/dosubot).*

---
<sup>How did I do? 
[Good](https://app.dosu.dev/response-feedback/08adac43-8311-403b-bb67-5b6be3ed2f0d?feedback_type=great_response)
 | 
[Irrelevant](https://app.dosu.dev/response-feedback/08adac43-8311-403b-bb67-5b6be3ed2f0d?feedback_type=irrelevant_answer)
 | 
[Incorrect](https://app.dosu.dev/response-feedback/08adac43-8311-403b-bb67-5b6be3ed2f0d?feedback_type=incorrect_sources)
 | 
[Verbose](https://app.dosu.dev/response-feedback/08adac43-8311-403b-bb67-5b6be3ed2f0d?feedback_type=too_verbose)
 | 
[Hallucination](https://app.dosu.dev/response-feedback/08adac43-8311-403b-bb67-5b6be3ed2f0d?feedback_type=hallucination)
 | [Report 
🐛](https://app.dosu.dev/response-feedback/08adac43-8311-403b-bb67-5b6be3ed2f0d?feedback_type=bug_report)
 | 
[Other](https://app.dosu.dev/response-feedback/08adac43-8311-403b-bb67-5b6be3ed2f0d?feedback_type=other)</sup>

[![Chat with 
Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=github)&nbsp;[![Open
 in 
Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=The%20date%20filter%27s%20inclusivity/exclusivity%20is%20hardcoded%20in%20two%20main%20places%3A%0A%0A-%20Frontend%3A%20In%20superset-frontend/src/explore/components/controls/DateFilterControl/components/AdvancedFrame.tsx%2C%20the%20UI%20labels%20and%20tooltips%20explicitly%20state%20%22Start%20%28inclusive%29%22%20and%20%22End%20%28exclusive%29%22%20and%20manage%20the%20date%20range%20as%20%22since%22%20and%20%22until%22%20values.%20You%27d%20need%20to%20update%20these%20labels%20and%20tooltips%20if%20you%20change%20the%20logic%20elsewhere.%20%20%0A%20%20%5BSee%20code%20reference%5D%28https%3A//github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/src/explore/components/controls/DateFilterControl/components/Advanc
 
edFrame.tsx%23L24-L85%29%0A%0A-%20Backend%3A%20In%20superset/utils/date_parser.py%2C%20the%20get_since_until%20function%20parses%20and%20normalizes%20the%20%22since%22%20and%20%22until%22%20values.%20By%20default%2C%20it%20produces%20ranges%20that%20are%20inclusive%20for%20the%20start%20and%20exclusive%20for%20the%20end%2C%20using%20expressions%20like%20DATETRUNC%20and%20DATEADD%20to%20define%20the%20end%20as%20the%20start%20of%20the%20next%20unit.%20%20%0A%20%20%5BSee%20code%20reference%5D%28https%3A//github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/utils/date_parser.py%23L314-L529%29%0A%0ATo%20make%20both%20endpoints%20inclusive%2C%20you%20would%20need%20to%3A%0A1.%20Update%20the%20frontend%20labels/tooltips%20to%20reflect%20the%20new%20behavior.%0A2.%20Change%20the%20backend%20logic%20so%20that%20the%20SQL%20filter%20uses%20%3C%3D%20for%20the%20end%20date%2C%20or%20adjust%20the%20%22until%22%20value%20to%20include%20the%20full%20end%20date%20%28fo
 
r%20example%2C%20by%20adding%20one%20day%20for%20day-level%20granularity%2C%20or%20one%20microsecond%20for%20timestamp-level%29.%0A%0ABe%20aware%20that%20this%20change%20can%20have%20side%20effects%2C%20especially%20with%20time%20granularity%20and%20timezone%20handling%2C%20so%20review%20any%20dashboards%20or%20queries%20that%20rely%20on%20the%20current%20%5Binclusive%2C%20exclusive%29%20behavior.)&nbsp;[![Join
 
Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share
 on 
X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/discussions/37192)

GitHub link: 
https://github.com/apache/superset/discussions/37192#discussioncomment-15514255

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: 
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to