SDU Tools are free tools and example T-SQL code for SQL Server developers and DBAs. WeekdayOfMonth is a function that calculates workdays (i.e. not weekends) within a month. It can work from the start of the month, or if you supply a negative parameter, from the end of the month. Parameter values that are out of range cause NULL to be returned.
To join SDU Insiders and get all our free resources, including SDU Tools, see the details at http://sdutools.sqldownunder.com