开发者

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

开发者 https://www.devze.com 2023-02-12 04:31 出处:网络
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 n开发者_如何学Pythonext monday...so basically:

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 n开发者_如何学Pythonext monday...so basically:

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

What is the easiest way to accomplish this?


Extract it from DateTime.

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

Paul


Use DATENAME as per MSDN.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号