Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
raja
Starting Member
18 Posts |
Posted - 2005-02-03 : 06:39:16
|
CREATE FUNCTION fnAddWorkingDays(@ScheduleSubDate AS Datetime,@NoOfWorkingDays AS INT) RETURNS Datetime AS BEGIN DECLARE @Counter AS INT DECLARE @ResultDate AS DATETIME DECLARE @NonWorkingDays AS INT DECLARE @tempWorkingDays AS INT SET @Counter = 0 SET @ResultDate = @ScheduleSubDate WHILE @Counter < @NoOfWorkingDays BEGIN SET @ResultDate = DATEADD(DAY,1,@ResultDate) IF (DATEPART(dw,@ResultDate) = 7) BEGIN SET @ResultDate = DATEADD(DAY,1,@ResultDate) END IF (DATEPART(dw,@ResultDate) = 1) BEGIN SET @ResultDate = DATEADD(DAY,1,@ResultDate) END SET @Counter = @Counter + 1 End RETURN @ResultDate END Functions Adds working days to the given date |
|
|
|
|