I created a table “daterange” with “startmonth”, “startday”, “endmonth”, “endday”. How can I use the data from “daterange” to filter the results from “annual_cultivation_dates_view”?
In a previous post I asked how-to-filter-date-range-entries-by-todays-date-or-another-date and this code worked: Maybe for someone with an better ability than me you can edit this code to include dates from “daterange” instead of current_date.
select
*
from
"annual_cultivation_dates_view"
where
current_date between
cast(
year(current_date)
|| '-' ||
right('0' || "start_month", 2)
|| '-' ||
right('0' || "start_day", 2)
as date)
and
cast(
case
when "start_month" <= "end_month" then
year(current_date)
else
year(current_date) + 1
end
|| '-' ||
right('0' || "end_month", 2)
|| '-' ||
right('0' || "end_day", 2)
as date)