I need to create a function in TSQL that will move the date to Monday if the date passed is either a Saturday or Sunday only.
For example:
- 5/6/2012 should return 5/7/2012
- 5/12/2012 should return 5/14/2012
If the date is not a Saturday or Sunday, return the input date
This will give you the Monday following if the date is a Saturday or Sunday; otherwise, it will give you the date you provided.
EDIT: Included Conrad Frix‘s solution to the @@DATEFIRST issue.