Calculating Number of Days excluding weekends (1 Viewer)

ndindi22

New member
Local time
Today, 00:46
Joined
Aug 16, 2007
Messages
2
Hi guys

Please help me with a function to calculate number of days between startdate and enddate excluding weekends. This is leave application where an employee get 1 day leave every after 17 days from the start date of contract. and the leave the accrue by 1 every after 17 days.

I'm using SQL server 2000

Please help
 

ndindi22

New member
Local time
Today, 00:46
Joined
Aug 16, 2007
Messages
2
Hi guys

This is what i've
SELECT
(DATEDIFF(dd, ContractStartDate, ContractEnddate) + 1)
-(DATEDIFF(wk, ContractStartDate, ContractEnddate) * 2)
-(CASE WHEN DATENAME(dw, ContractStartDate) = 'Sunday' THEN 1 ELSE 0 END)
-(CASE WHEN DATENAME(dw, ContractEnddate) = 'Saturday' THEN 1 ELSE 0 END)
/17
from contract

and it's calculating fine days between ContractStartDate and ContractEnddate. But now I want to have another column that is going to calculate no of leave days, every after 17 woking days the employee gets 1 day leave and it accrue by 1 every after 17 woking days.

Can someone plz help....

ndindi22
 

Users who are viewing this thread

Top Bottom