GitHub user dosubot[bot] added a comment to the discussion: Date Filter
<!-- Answer -->
To make the custom date filter range inclusive of the end date, edit
superset/utils/date_parser.py in the get_since_until function. Right after the
line where _since and _until are set for custom ranges (after _since, _until =
map(datetime_eval, since_and_until)), add one day to _until. Here’s how you can
do it:
Find this block (around line 467):
```python
_since, _until = map(datetime_eval, since_and_until)
```
Immediately after, insert:
```python
from datetime import timedelta
# Make custom range end date inclusive by adding one day
if _until is not None:
_until = _until + timedelta(days=1)
```
This ensures that, for custom ranges, the filter will include the
user-specified end date for day-level granularity. If you need finer control
(e.g., for timestamp-level), you may want to adjust the timedelta accordingly.
Be sure to test this change, as it may affect how date filters behave elsewhere
in your dashboards.
Reference: [superset/utils/date_parser.py get_since_until
function](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/utils/date_parser.py#L314-L529)
<!-- 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/375fd321-7e54-49a2-9091-436c71ef9e01?feedback_type=great_response)
|
[Irrelevant](https://app.dosu.dev/response-feedback/375fd321-7e54-49a2-9091-436c71ef9e01?feedback_type=irrelevant_answer)
|
[Incorrect](https://app.dosu.dev/response-feedback/375fd321-7e54-49a2-9091-436c71ef9e01?feedback_type=incorrect_sources)
|
[Verbose](https://app.dosu.dev/response-feedback/375fd321-7e54-49a2-9091-436c71ef9e01?feedback_type=too_verbose)
|
[Hallucination](https://app.dosu.dev/response-feedback/375fd321-7e54-49a2-9091-436c71ef9e01?feedback_type=hallucination)
| [Report
🐛](https://app.dosu.dev/response-feedback/375fd321-7e54-49a2-9091-436c71ef9e01?feedback_type=bug_report)
|
[Other](https://app.dosu.dev/response-feedback/375fd321-7e54-49a2-9091-436c71ef9e01?feedback_type=other)</sup>
[](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=github) [](https://cursor.com/link/prompt?text=To%20make%20the%20custom%20date%20filter%20range%20inclusive%20of%20the%20end%20date%2C%20edit%20superset/utils/date_parser.py%20in%20the%20get_since_until%20function.%20Right%20after%20the%20line%20where%20_since%20and%20_until%20are%20set%20for%20custom%20ranges%20%28after%20_since%2C%20_until%20%3D%20map%28datetime_eval%2C%20since_and_until%29%29%2C%20add%20one%20day%20to%20_until.%20Here%E2%80%99s%20how%20you%20can%20do%20it%3A%0A%0AFind%20this%20block%20%28around%20line%20467%29%3A%0A%0A%60%60%60python%0A_since%2C%20_until%20%3D%20map%28datetime_eval%2C%20since_and_until%29%0A%60%60%60%0A%0AImmediately%20after%2C%20insert%3A%0A%0A%60%60%60python%0Afrom%20datetime%20import%20timedelta%0A%0A%23%20Make%20custom%20range%20end%20date%20inclusive%20by%
20adding%20one%20day%0Aif%20_until%20is%20not%20None%3A%0A%20%20%20%20_until%20%3D%20_until%20%2B%20timedelta%28days%3D1%29%0A%60%60%60%0A%0AThis%20ensures%20that%2C%20for%20custom%20ranges%2C%20the%20filter%20will%20include%20the%20user-specified%20end%20date%20for%20day-level%20granularity.%20If%20you%20need%20finer%20control%20%28e.g.%2C%20for%20timestamp-level%29%2C%20you%20may%20want%20to%20adjust%20the%20timedelta%20accordingly.%20Be%20sure%20to%20test%20this%20change%2C%20as%20it%20may%20affect%20how%20date%20filters%20behave%20elsewhere%20in%20your%20dashboards.%0A%0AReference%3A%20%5Bsuperset/utils/date_parser.py%20get_since_until%20function%5D%28https%3A//github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/utils/date_parser.py%23L314-L529%29) [](https://go.dosu.dev/discord-bot) [](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-15515258
----
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]