Conditionally Query based on Time range control settings

I have a postgres - timescale db and would like to conditionally run one of the following queries

Run query 1 if Time range controls < 2 days
Run query 2 if Time range controls > 2 days

Query 1

SELECT
    time_bucket('1 hour', ts) AS time,
    SUM(CAST (value_string AS DECIMAL)) as "Run Time"
FROM data
WHERE
      $__timeFilter(ts) 
GROUP BY time
ORDER BY time

Query 2

SELECT
    time_bucket('1 day', ts) AS time,
    SUM(CAST (value_string AS DECIMAL)) as "Run Time"
FROM data
WHERE
      $__timeFilter(ts) 
GROUP BY time
ORDER BY time