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.
| Author |
Topic |
|
khufiamalik
Posting Yak Master
120 Posts |
Posted - 2010-02-20 : 02:23:03
|
| Hello all,I have 2 Date variables which are @Employee_Joining_Date and @Employee_Resign_Date.I have to calculate the total Number of Job Days BUT if there is any Leap Year(s) between theses 2 dates then ignore the LEAP DAY.any Idea ? |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-02-20 : 02:33:41
|
| [code]DECLARE @Employee_Joining_Date datetime, @Employee_Resign_Date datetimeSELECT @Employee_Joining_Date='20040831',@Employee_Resign_Date='20091223'SELECT COUNT(CASE WHEN DAY([Date]) = 29 AND MONTH([Date])= 2 THEN NULL ELSE 1 END) AS NonLeapCountJobDaysFROM dbo.CalendarTable(@Employee_Joining_Date,@Employee_Resign_Date,1)calendartable function can be found athttp://visakhm.blogspot.com/2010/02/generating-calendar-table.htmloutput------------------NonLeapCountJobDays1386[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
khufiamalik
Posting Yak Master
120 Posts |
Posted - 2010-02-20 : 03:13:13
|
| Thanks Alot |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-02-20 : 03:13:54
|
welcome ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|