Quote Originally Posted by Ellis Dee View Post
Note that in your first example, Start is after End. That's not supported.
That's fair enough, it's a very easy fix anyway (for others reading later: just swap the dates), I just thought I'd mention it in case you'd had successful tests.

Quote Originally Posted by Ellis Dee View Post
I was unable to figure out how to account for the root problem. I successfully added an exception for months = 2 to 12, but the problem persisted with years and I couldn't readily solve that one. Which meant I ended up coding special logic for both months/days and years/months, so at this point I may as well do it straight up like in the OP since it's easier to maintain and includes weeks.
I haven't thought of a clever fix for the previous code (just the kind of thing you would have tried), so that's probably the way to go.

Keeping code short is nice, but correctness and maintainability are more important.