stephen776
stephen776

Reputation: 9234

SQL Server 2008- If date falls on weekend, Increase to next Monday

In SQL Server I am calculating a date based on certain business rules. If the date falls on a weekend I need to move it up to the next monday...so basically:

if(date == saturday)
{
 add 2 days
}
if(date == sunday)
{
  add 2 day
}

What is the easiest way to accomplish this?

Upvotes: 1

Views: 2224

Answers (2)

vonPryz
vonPryz

Reputation: 24071

Use DATENAME as per MSDN.

Example: select datename(weekday, getdate()) returns Thursday as of today.

Upvotes: 1

Young Grasshopper
Young Grasshopper

Reputation: 354

Extract it from DateTime.

http://msdn.microsoft.com/en-us/library/bb762911.aspx

Paul

Upvotes: 3

Related Questions