Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Other SQL Server 2008 Topics
 Calculate leave days from startdate to enddate

Author  Topic 

ndindi22
Starting Member

14 Posts

Posted - 2007-08-16 : 06:07:24

Can someone plz help me.

I'm working on leave application, have to calculate number of leave days available, starting from Startdate to Enddate of a contract. Where an employee get 1 day leave after 17 days from startdate of contract. How do I calculate the leave days, that accrue every after 17 days by 1.

I'm using ASP and SQL Server 2000 (Query Analyzer)

ndindi22

ndindi22

ditch
Master Smack Fu Yak Hacker

1466 Posts

Posted - 2007-08-16 : 06:13:01
Cross Post http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=87926

Please don't do that

Duane.
Go to Top of Page

ashley.sql
Constraint Violating Yak Guru

299 Posts

Posted - 2007-08-16 : 08:34:40
you need to follow the logic

or maybe you can divide the difference between enddate and startdate by 17 and use the quotient as the number of days of leave

so if someone worked for 100 days

select datediff(d, '1/15/2007', '4/25/2007')/17 here you will get 5
but you will use
select datediff(d, startdate, enddate)/17 as 'NUMBER OF LEAVES'

Ashley Rhodes
Go to Top of Page

ashley.sql
Constraint Violating Yak Guru

299 Posts

Posted - 2007-08-16 : 08:36:32
also you did not mention if its 17 business days or just 17 days.

If its business days its different and can be done with a function which calculates business days between 2 dates
and then you can divide that number by 17.



Ashley Rhodes
Go to Top of Page
   

- Advertisement -