Hi I'm struggling to find an elegant way of determining whether the date from a record falls within a number of date boundaries ranges.
For example in a separate (date boundaries) table I code the "Winter Season" running from 1/11 to 28/2 and the "Summer Season" running from 1/4 to 31/7. I have day1, day2... and month1, month2... fields for each season
I'm try to build something like Select * from tab1 where date between 1/11/year(date) and 28/2/year(date) except I get the day and month numbers from the date boundaries table using a sub select.
Using the long winded approach:
but as you see its unwieldy and I'm disappearing up my ... well you know where!
Is there a better way?
Rgds, Phil
For example in a separate (date boundaries) table I code the "Winter Season" running from 1/11 to 28/2 and the "Summer Season" running from 1/4 to 31/7. I have day1, day2... and month1, month2... fields for each season
I'm try to build something like Select * from tab1 where date between 1/11/year(date) and 28/2/year(date) except I get the day and month numbers from the date boundaries table using a sub select.
Using the long winded approach:
Code:
PARAMETERS season_requested Text ( 255 ); SELECT [T\RAB Data].Species, [T\RAB Data].Date FROM [T\RAB Data] WHERE [T\RAB Data].Species='species name' AND (Day([date]) Between (select [start day 1] from [season boundaries] where season = [season_requested]) And (select [end day 1] from [season boundaries] where season = [season_requested]) and Month([date]) Between (select [start month 1] from [season boundaries] where season = [season_requested]) And (select [end month 1] from [season boundaries] where season = [season_requested]) OR Day([date]) Between (select [start day 2] from [season boundaries] where season = [season_requested]) And (select [end day 2] from [season boundaries] where season = [season_requested]) and Month([date]) Between (select [start month 2] from [season boundaries] where season = [season_requested]) And (select [end month 2] from [season boundaries] where season = [season_requested]) OR Day([date]) Between (select [start day 3] from [season boundaries] where season = [season_requested]) And (select [end day 3] from [season boundaries] where season = [season_requested]) and Month([date]) Between (select [start month 3] from [season boundaries] where season = [season_requested]) And (select [end month 3] from [season boundaries] where season = [season_requested]));
Is there a better way?
Rgds, Phil
Comment