I am trying to make a holiday booking application and it runs of a JQuery UI calendar. the star and end date they select are passed to SQL where it puts the holiday into the requested table. the only problem is if i put a start and an end date in, it doesn't take into account the weekends. each user of the system has 21 days allowance off per calendar year and it deducts the weekends of this also. here is the current code.
SET @DateDiff = (DATEDIFF(Day,@StartDate,@EndDate) +1)
Above is the date-diff statement and below is the insertion code
BEGIN
INSERT INTO Holidays(EmployeeID, StartDate, EndDate, Duration,Status)
VALUES(@EmployeeID, @StartDate, @EndDate, @DateDiff,'PE')
UPDATE Employees
SET AnnualDaysHolidayAllowance = AnnualDaysHolidayAllowance - @DateDiff
WHERE ID = @EmployeeID
SELECT 'successful' AS result
END
There is more code for the business checks and rules but this is the only part i need to try and fix. i am relatively new to coding so if possible please leave an explanation to help me understand the fix, thanks.