• Thanks for the post Wayne, I will point all developers of convoluted datetime function hacks to this article for education.

    I always find simplicity in code to be a beautiful thing, can I make a small suggestion on the DateAdd function you use?

    We use

    DATEADD(MONTH, DATEDIFF(MONTH, 0, SomeDate), 0) -- as inspired by Rob Farley

    and make use of the implicit conversion of 0 to a base date. We also use the value to add offsets to the date calculation,

    so I'm thinking the new functionality may well go unused here.