SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Other SQL Server 2008 Topics
 Calculate leave days from startdate to enddate
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

ndindi22
Starting Member

South Africa
14 Posts

Posted - 08/16/2007 :  06:07:24  Show Profile  Visit ndindi22's Homepage  Reply with Quote

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
Flowing Fount of Yak Knowledge

South Africa
1466 Posts

Posted - 08/16/2007 :  06:13:01  Show Profile  Visit ditch's Homepage  Reply with Quote
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

USA
299 Posts

Posted - 08/16/2007 :  08:34:40  Show Profile  Reply with Quote
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

USA
299 Posts

Posted - 08/16/2007 :  08:36:32  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.04 seconds. Powered By: Snitz Forums 2000