Include Start Date and the End Date in DateDiff function

10,183

Solution 1

Just add 1:

select  datediff(day, [Start Date], [End Date]) + 1 as NumberOfDays
from    YourTable

Solution 2

You may try this in SQL SERVER:

DATEDIFF(DAY, '8/4/2014', '8/5/2014') +1

You need to add 1 to the DATEDIFF function and it will work as you want.

Also to note that:

DATEDIFF

Returns the count (signed integer) of the specified datepart boundaries crossed between the specified startdate and enddate.

Share:
10,183
TontoDiablo
Author by

TontoDiablo

Updated on June 04, 2022

Comments

  • TontoDiablo
    TontoDiablo almost 2 years

    I'm looking to get total number of days including the Start Date and End Date, some examples below:

    Start Date  End Date     Tot#Days
    08-04-2014  08-04-2014   1
    08-04-2014  08-05-2014   2
    08-04-2014  08-07-2014   4
    

    I tried using the DATEDIFF function however I get a 0 for the first example, 1 for second example and 3 for the third which is not what I'm after.