Michael Valentine Jones (1/9/2012)
I simplified my original code to eliminate three DATEADD function calls and one NULLIF function call, so it might run a bit faster.
It seems a little slower on my instances; fastest run out of 10 was 1210ms (versus 1155ms previously).
Paul White
SQLPerformance.com
SQLkiwi blog
@SQL_Kiwi