Creating server independent day comparison logic in Transact SQL

There are quite a few occasions where we require writing logic based on day comparisons from a date value. Some of the common scenarios include Counting days elapsed between two dates excluding  weekends Getting the Thursday (or any other day) of…