It’s not so hard to look at and work with when you are looking right at one.
It becomes a different thing to work with when you are trying to calculate dynamically with it. It’s not overly difficult, it just has the potential to make me stop in my tracks and think about the logic being used.
It happened today. I started this week hoping to get to work, finish off one project inside of a short time, and move on to something different. Monday was severely flooded, I couldn’t get access to work – to uhh work. Roads were flooded. Half the day wasted on account of the rain.
I started today hoping to finish what I was working on, and by mid after noon began pondering how I’d make the ability to use two date ranges work together.
There are two date ranges, one represents the set of collected data, the data range. The other represents the variable(s) applicable to that data set – the variables are date ranges.
So to make them work, I come across issues such as – how do we work with the date of the variables being ‘after’ the reporting data set (a very real possibility, I anticipate seeing the variable date ranges begin and end with overlapping data periods.
Thinking more of it tonight, I figured this is the best representation of what must be done (in logic terms):
if (dataDateStart < variableDateStart) then if (variableDateEnd < dataDateEnd) then //days involved is the days between variableDateStart and variableDateEnd else if (variableDateEnd >= dataDateEnd) then
//days involved is the days between varaibleDateStart and dataDateEnd
else //if dataDateStart >= variableDateStart)
if (variableDateEnd < dataDateEnd) then //days involved is the days between dataDateStart and variableDateEnd else if (variableDateEnd >= dataDateEnd) then
//days involved is the days between dataDateStart and dataDateEnd
That gives the complete desired overlap needed when considering the variables.
If the variables don’t meet the data date ranges, that becomes a user error (otherwise the loop fetches multiple records with multiple date ranges and acts accordingly).
It’s not overly difficult in the basic form, I just don’t always see the simple when thinking of how to make it work.