Want to become a Vibe Coder? Join Vibe Coding Training here
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Extend DATEADD function to skip weekend days
WhatsApp
Emiliano Musso
Apr 17
2015
1.1
k
0
0
CREATE FUNCTION
DAYSADDNOWK(@addDate
AS
DATE
, @numDays
AS
INT
)
RETURNS
DATETIME
AS
BEGIN
SET
@addDate = DATEADD(d, @numDays, @addDate)
IF DATENAME(DW, @addDate) =
'sunday'
SET
@addDate = DATEADD(d, 1, @addDate)
IF DATENAME(DW, @addDate) =
'saturday'
S
ET
@addDate = DATEADD(d, 2, @addDate)
RETURN
CAST
(@addDate
AS
DATETIME)
END
GO
tsql
sql
sql server
programming
Up Next
Extend DATEADD function to skip weekend days