• Thanks for the great function..but i do have further calrifications...the weekends in uae are Thursdays & fridays. I modified the code to match the weekends but get wrong results..any help on this??

    the code is

    RETURN (

                    SELECT

                  --Start with total number of days including weekends

                    (DATEDIFF(dd,@StartDate,@EndDate)+1)

                  --Subtact 2 days for each full weekend

                   -(DATEDIFF(wk,@StartDate,@EndDate)*2)

                  --If StartDate is a Sunday, Subtract 1

                   -(CASE WHEN DATENAME(dw,@StartDate) = Friday

                          THEN 1

                          ELSE 0

                      END)

                  --If EndDate is a Saturday, Subtract 1

                   -(CASE WHEN DATENAME(dw,@EndDate) = Thursday

                          THEN 1

                          ELSE 0

                      END)

                    )

     

    when i enter @StartDate = '07/08/2005',@EndDate='07/14/2005'

    I get 3..which is wrong..

    waiting for urgent help...