July 5, 2012 at 12:28 pm
Comments posted to this topic are about the item BussinesDaysToCalendarDays
July 13, 2012 at 12:23 pm
Alter Function GetCalanderDaysFromBusinessDays (@BusinessDay int)
Returns Date
as
Begin
Declare @CalanderDays int
Declare @FinalDate Date
Set @CalanderDays = ((@BusinessDay/5)*7) + (@BusinessDay % 5)
Set @FinalDate = DateAdd(Day, @CalanderDays, GetDate())
Return @FinalDate
End
July 13, 2012 at 12:48 pm
Hi Parajuli,
I like your formula, is neat. But i found it does not produce a correct result for one case.
Look, if the bussinesweek is Monday to Friday, and I run this procedure in a wednesday setting the parameter @BussinesDay = 4, the result should be that the final date is next Monday ( Wednesday 1, Thursday 2, Friday 3, Monday 4), but the below query tells me that final date is Sunday. You see anything missplaced in my test?
DECLARE @BusinessDay INT;
SET @BusinessDay = 4
Declare @CalanderDays int
Declare @FinalDate Datetime
Set @CalanderDays = ((@BusinessDay/5)*7) + (@BusinessDay % 5)
Set @FinalDate = DateAdd(Day, @CalanderDays, '2012-07-11') -- Wednesday
select @FinalDate, datename (Weekday,@finalDate)
July 20, 2012 at 6:46 am
Not sure which one works...but h.parajuli can spell BUSINESS correctly unlike Adrian.
July 20, 2012 at 6:53 am
But unfortunately h.parajuli cannot spell CALENDAR.
July 20, 2012 at 7:12 am
Ha ha i haven't noticed it. Parajuli and I have some homework to do =).
May 10, 2016 at 9:21 am
Thanks for the script.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply