dosubot[bot] commented on issue #40119: URL: https://github.com/apache/superset/issues/40119#issuecomment-4451253074
<!-- Greeting --> Hi @ketansharma78! I'm [Dosu](https://go.dosu.dev/dosubot) and Iām helping the superset team. <!-- Answer --> The `get_time_filter()` function is **not available in Superset 4.0.2** ā it was introduced in **version 4.1.0** (PR #30142 merged on September 6, 2024, after the 4.0.2 release on June 26, 2024) [[1]](https://github.com/apache/superset/pull/30142). **For Superset 4.0.2**, you can use the legacy Jinja variables `from_dttm` and `to_dttm` to pass dynamic date ranges into your query: ```sql SELECT * FROM my_table WHERE 1 = 1 {% if from_dttm %}AND my_date_column >= '{{ from_dttm }}'{% endif %} {% if to_dttm %}AND my_date_column < '{{ to_dttm }}'{% endif %} ``` These variables are populated from the time range filter applied in the chart's Explore view or from dashboard native time range filters [[2]](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/docs/docs/configuration/sql-templating.mdx#L20-L21). You can also use `filter_values()` to retrieve values from other filter components [[3]](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/jinja_context.py#L287-L326). **Regarding the 403 Forbidden error** when editing/saving datasets or metrics ā this is typically a permissions issue. Ensure the user's role has the following permissions: - `can write` on `Dataset` - `can read` / `can write` on `Metric` - Ownership or appropriate data access on the relevant database/schema If you're using a custom role (e.g., based on Gamma), you may need to explicitly add dataset write permissions. **Best path forward**: If possible, upgrading to **4.1.0+** would give you access to `get_time_filter()` with its structured output and database-aware formatting, which is the recommended approach for dynamic date filtering in virtual datasets. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=reply-with-mention&utm_term=apache%2Fsuperset).* --- Docs are dead. Just use [Dosu](https://dosu.dev?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=static-docs-tagline&utm_term=apache%2Fsuperset). [](https://app.dosu.dev/response-feedback?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=static-docs-feedback&utm_term=apache%2Fsuperset&message_id=521b437f-1f8e-4b71-8365-72550a6184e5) [](https://github.dosu.com/apache/superset?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=static-docs-ask-repo&utm_term=apache%2Fsuperset) [](https://app.dosu.dev/signup?referrer=openSource&source=github-footer&utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=static-docs-share-team&utm_term=apache%2Fsuperset) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
