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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

 SQL Server Forums Profile | Active Topics | Members | Search | Forum FAQ Register Now and get your question answered!
 All Forums  SQL Server 2008 Forums  Other SQL Server 2008 Topics  Calculate leave days from startdate to enddate Reply to Topic  Printer Friendly
Author  Topic

ndindi22
Starting Member

South Africa
14 Posts

 Posted - 08/16/2007 :  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)ndindi22ndindi22

ditch
Flowing Fount of Yak Knowledge

South Africa
1466 Posts

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

ashley.sql
Constraint Violating Yak Guru

USA
299 Posts

 Posted - 08/16/2007 :  08:34:40 you need to follow the logicor maybe you can divide the difference between enddate and startdate by 17 and use the quotient as the number of days of leaveso if someone worked for 100 daysselect datediff(d, '1/15/2007', '4/25/2007')/17 here you will get 5but you will useselect datediff(d, startdate, enddate)/17 as 'NUMBER OF LEAVES'Ashley Rhodes

ashley.sql
Constraint Violating Yak Guru

USA
299 Posts

 Posted - 08/16/2007 :  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 datesand then you can divide that number by 17.Ashley Rhodes
Topic
 Reply to Topic  Printer Friendly Jump To: Select Forum General SQL Server Forums       New to SQL Server Programming       New to SQL Server Administration       Script Library       Data Corruption Issues       Database Design and Application Architecture SQL Server 2012 Forums       Transact-SQL (2012)       SQL Server Administration (2012)       SSIS and Import/Export (2012)       Analysis Server and Reporting Services (2012)       Replication (2012)       Availability Groups and DR (2012)       Other SQL Server 2012 Topics SQL Server 2008 Forums       Transact-SQL (2008)       SQL Server Administration (2008)       SSIS and Import/Export (2008)       High Availability (2008)       Replication (2008)       Analysis Server and Reporting Services (2008)       Other SQL Server 2008 Topics SQL Server 2005 Forums       Transact-SQL (2005)       SQL Server Administration (2005)       .NET Inside SQL Server (2005)       SSIS and Import/Export (2005)       Service Broker (2005)       Replication (2005)       High Availability (2005)       Analysis Server and Reporting Services (2005)       Express Edition and Compact Edition (2005)       Other SQL Server Topics (2005) SQL Server 2000 Forums       SQL Server Development (2000)       SQL Server Administration (2000)       Import/Export (DTS) and Replication (2000)       Transact-SQL (2000)       Analysis Services (2000)       MSDE (2000) Development Tools       ASP.NET       Reporting Services Development       Other Development Tools Site Related Forums       Site Related Discussions       Article Discussion       Poll Discussion       The Yak Corral Other Forums       SQL Server 6.5 \ SQL Server 7.0       Other Topics       MS Access       ClearTrace Support Forum Old Forums       CLOSED - General SQL Server       CLOSED - SQL Server 2005/Yukon  -------------------- Home Active Topics Frequently Asked Questions Member Information Search Page
 SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC