SDU Tools: Start of week and End of week in SQL Server T-SQL

I get really good feedback all the time from users of our free SDU Tools for developers and DBAs, but none more than when we have more and more date and time functions. One pair of functions that we added in v19 that was recently shipped was StartOfWeek and EndOfWeek.
These are simple scalar functions that take a single date parameter, and return the date for the start and end of the week that contains the date provided.
Note: we’ve assumed that weeks start on Sunday and end on Saturday as it common in many Western countries but I know, for example, that my Chinese friends consider Monday the start of the week. It’s easy to change the functions to achieve that as well.
You can use our tools as a set or as a great example of how to write functions like these.
Find out more
You can see it in action in the main image above, and in the video here:
Access to SDU Tools is one of the benefits of being an SDU Insider, along with access to our other free tools and eBooks. Please just visit here for more info:
http://sdutools.sqldownunder.com
2020-04-15