August 4, 2012 at 3:14 pm
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!
August 4, 2012 at 4:47 pm
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
August 5, 2012 at 2:03 am
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:
August 5, 2012 at 2:35 pm
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