Summing Columns of Dates

  • I have 2 columns of dates. What I need to do is to sum or count days in between. I know that there is the Datediff function. My problem is that I am trying to sum a startdate and an enddate. But if the start date starts on 6/1/2012 and ends on 6/1/2012 then I want to count this as 1. Can anyone please give me some guidance thanks in advance!

  • pkaraffa (8/4/2012)


    I have 2 columns of dates. What I need to do is to sum or count days in between. I know that there is the Datediff function. My problem is that I am trying to sum a startdate and an enddate. But if the start date starts on 6/1/2012 and ends on 6/1/2012 then I want to count this as 1. Can anyone please give me some guidance thanks in advance!

    DATEDIFF(dd,@StartDate,@EndDate) + 1

  • case when @StartDate<@EndDate then

    DATEDIFF(dd,@StartDate,@EndDate) + 1

    when @StartDate>@EndDate then DATEDIFF(dd,@StartDate,@EndDate) - 1 end

    ~ demonfox
    ___________________________________________________________________
    Wondering what I would do next , when I am done with this one :ermm:

  • Thank you both worked great!

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply