# Dynamic params to use with Data Explorer

**URL:** <https://meta.discourse.org/t/dynamic-params-to-use-with-data-explorer/346502>\
**Category:** Data & reporting\
**Tags:** sql-query\
**Created:** [January 10, 2025, 11:51am UTC](https://meta.discourse.org/t/dynamic-params-to-use-with-data-explorer/346502 "2025-01-10T11:51:12Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![Moin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/moin/32/554653_2.png) [@Moin](https://meta.discourse.org/u/Moin)\
**Post date:** [February 6, 2025, 9:25pm UTC](https://meta.discourse.org/t/dynamic-params-to-use-with-data-explorer/346502/5 "2025-02-06T21:25:40Z")

</div>

Would it work to move the defaults into the query and use them as long as no date is selected? So, something like this:

```sql
-- [params]
-- null date :start_date
-- null date :end_date

SELECT id as topic_id, created_at
FROM topics
WHERE created_at > COALESCE(:start_date, CAST(date_trunc('week', current_date) AS DATE))
AND created_at < COALESCE(:end_date, CAST(date_trunc('week', current_date) AS DATE)+4)

```

---

_[View the full topic](https://meta.discourse.org/t/dynamic-params-to-use-with-data-explorer/346502)._
