Depending on your time series data, for your graphs/charts, the x-axis range may look too wide. To resolve this problem, you can add a time series for the start and end date of a time series. There are 2 ways to resolve this problem
Solution 1: Create 2 parameters
You can make 2 parameters, a start date and an end date, and then use “>”, “>=”, “<”, “<=” in the WHERE clause.
SELECT
data1,
data2,
date
FROM bio_data
WHERE date >= #{{Start Date}} and date <= #{{End Date}}
“>=” and “<=” mean greater/less than or equal to. This means that the date range is inclusive to the start or end date. If instead you’d like to filter by “dates between #{{Start Date}} and #{{End Date}} parameter”, you can use “<” and “>”.
Solution 2: Handle null values
SELECT
data1,
data2,
date
FROM bio_data
WHERE (#{{Start Date}} is null or date >= #{{Start Date}})
and (#{{End Date}} is null or date <= #{{End Date}})
In addition to the solution 1, this query allows to specify a date range with the #{{Start Date}} and #{{End Date}} parameters. You can also leave both as null to have the full range, or you can set either one to have ranges like “up until the end date” or “from the start date”.