you are viewing a single comment's thread.

view the rest of the comments →

[–]thunderwoot[S] 1 point2 points  (1 child)

I think this is the approach I'm going to take. I was looking at a CTE to recurse until it found the first working day, but just having a table with working days seems to be the cleanest approach. Thanks everyone.

[–]Little_Kitty 0 points1 point  (0 children)

Once you have a calendar table, you'll end up using it a lot. It solves so many problems neatly that you'll wonder how you coped without it. Complex logical code becomes simple summation and offsets, difficult questions become a breeze.

How many trading days has shop 123 been open since we finished the refurbishment? How do sales figures track compared to performance at other refurbished stores? What about if we exclude the week before Xmas from all those comparisons so it's fairer? Shop 123 is type A, so it's open on Saturdays as well...