• Hi Rob,

    While the function uses some nifty tricks (I particularly like the trick to get correct results regardless of datefirst setting; this is a new trick for me), I'd never recommend using this function to anyone.

    There are other ways to achieve this. Ways that are, in my opinion, better. Check out http://www.aspfaq.com/show.asp?id=2519, and especially the section titled "Pre-determine delivery dates".

    Best, Hugo


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/