Hi,
Thanks for the code. It really useful.
Can you please explain the logic, so it will be easy to understand how it works.
When @days are less than 0 you have done
SELECT @weeks = (datepart (dw, @date) + @days - 6)/5
and when @days are greater than 0
then
SELECT @weeks = (DATEPART (dw, @date) + @days - 2)/5
how it works.
Thanks & Regards,