Click here to Skip to main content
16,005,734 members
Home / Discussions / Database
   

Database

 
AnswerRe: sql view Pin
_Damian S_3-Jun-09 16:04
professional_Damian S_3-Jun-09 16:04 
AnswerRe: sql view Pin
A k ch4-Jun-09 22:09
A k ch4-Jun-09 22:09 
Questioncreate proc from assembly Pin
Abdul Rahman Hamidy2-Jun-09 21:22
Abdul Rahman Hamidy2-Jun-09 21:22 
AnswerRe: create proc from assembly Pin
Abdul Rahman Hamidy2-Jun-09 22:01
Abdul Rahman Hamidy2-Jun-09 22:01 
GeneralRe: create proc from assembly Pin
Abdul Rahman Hamidy2-Jun-09 22:10
Abdul Rahman Hamidy2-Jun-09 22:10 
QuestionFind working hours between two dates Pin
Rajesh VR2-Jun-09 20:31
Rajesh VR2-Jun-09 20:31 
AnswerRe: Find working hours between two dates Pin
Blue_Boy2-Jun-09 20:54
Blue_Boy2-Jun-09 20:54 
AnswerSQL function GetBusinessDays Pin
David Mujica3-Jun-09 2:58
David Mujica3-Jun-09 2:58 
Here is what I've used in the past ...

Notice that there is a commented out function call reference that allows for custom logic to provide for holidays to be not considered working days. You would have to code the "IsDateAHoliday" function yourself.


-- You can try this out by invoking the statement: select dbo.GetBusinessDays(cast ('10/01/2007' as datetime),cast('10/09/2007' as datetime))

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go


-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date, ,>
-- Description:	<Description, ,>
-- =============================================
ALTER function [dbo].[GetBusinessDays]
(
     @StartDate datetime,
     @EndDate datetime
) 
returns int
 as
begin

  declare @DaysBetween int
  declare @BusinessDays int
  declare @Cnt int
  declare @EvalDate datetime

  select @DaysBetween = 0
  select @BusinessDays = 0
  select @Cnt=0

  select @DaysBetween = datediff(Day,@StartDate,@endDate) + 1  
   
   while @Cnt < @DaysBetween
     begin
  
            select @EvalDate = @StartDate + @Cnt
        
            --if (dbo.IsDateAHoliday(@EvalDate)  = 0)
            --BEGIN
                if ((datepart(dw,@EvalDate) <> 1) and (datepart(dw,@EvalDate) <> 7))
                    BEGIN
                         select @BusinessDays = @BusinessDays + 1
                    END
            --END
      
          select @Cnt = @Cnt + 1
    end

 return @BusinessDays
end

QuestionProblem with Bulk insert and insert trigger Pin
www.Developerof.NET2-Jun-09 18:45
www.Developerof.NET2-Jun-09 18:45 
QuestionAll Sql Command Pin
Satish Pai2-Jun-09 18:19
Satish Pai2-Jun-09 18:19 
AnswerRe: All Sql Command Pin
Ashfield2-Jun-09 21:01
Ashfield2-Jun-09 21:01 
AnswerRe: All Sql Command Pin
RussellT5-Jun-09 10:36
professionalRussellT5-Jun-09 10:36 
AnswerRe: All Sql Command Pin
Niladri_Biswas25-Jun-09 5:54
Niladri_Biswas25-Jun-09 5:54 
QuestionSQL Injection Pin
AlexeiXX32-Jun-09 16:23
AlexeiXX32-Jun-09 16:23 
AnswerRe: SQL Injection Pin
_Damian S_2-Jun-09 18:08
professional_Damian S_2-Jun-09 18:08 
Questionsql Pin
jainiraj2-Jun-09 4:25
jainiraj2-Jun-09 4:25 
AnswerRe: sql Pin
Tim Carmichael2-Jun-09 5:56
Tim Carmichael2-Jun-09 5:56 
GeneralRe: sql Pin
jainiraj2-Jun-09 18:54
jainiraj2-Jun-09 18:54 
GeneralRe: sql Pin
_Damian S_2-Jun-09 19:16
professional_Damian S_2-Jun-09 19:16 
QuestionHelp - Need Location Independent Dating Pin
Hypermommy2-Jun-09 3:07
Hypermommy2-Jun-09 3:07 
AnswerRe: Help - Need Location Independent Dating Pin
Luc Pattyn2-Jun-09 3:32
sitebuilderLuc Pattyn2-Jun-09 3:32 
QuestionStrongly Typed DataSet help Pin
Etienne_1231-Jun-09 22:34
Etienne_1231-Jun-09 22:34 
AnswerRe: Strongly Typed DataSet help Pin
AlexeiXX32-Jun-09 16:27
AlexeiXX32-Jun-09 16:27 
QuestionService Account Pin
Satish Pai1-Jun-09 18:50
Satish Pai1-Jun-09 18:50 
AnswerRe: Service Account Pin
Niladri_Biswas7-Jun-09 0:12
Niladri_Biswas7-Jun-09 0:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.