• With reporting requirements of this type, it's standard to use a Date Dimension.

    This makes your code much less complex - and therefore more maintainable, it's orders of magnitude easier when reporting periods change (or even just the format of a reporting period description), you run one update against the values in the column rather than have to track down and update te complicated bits of code scattered through your codebase. It's also more efficient as you're simply adding a join rather than doing expensive calculations

    I'm a DBA.
    I'm not paid to solve problems. I'm paid to prevent them.