![]() (DATEDIFF(wk,d.StartDate,d.EndDate)*2) -Subtact 2 days for each full weekend (DATEDIFF(dd,d.StartDate,d.EndDate)+1) -Start with total number of days including weekends It still works just fine in 2005, as well. Since I originally wrote that function for SQL Server 2000, which was before the advent of CTEs and Cross Apply (which is really just a correlated subquery), here's how I would write the function now for SQL Server 2000 to get away from the RBAR nature of Scalar Functions altogether. They're just a part of "Divide'n'Conquer'. ![]() ![]() Control-of-flow statements, like IF, have nothing to do with whether or not something is set-based or not. It has been a long time and a lot of water has flowed under the proverbial bridge. SELECT = > to stick with the set-based coding theme. = If the inputs are in the wrong order, reverse them I read your article and I know it's been a loooooooooooooooong time but you know you could replace this:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |