Reputation: 275
Generally this is used for getting the number of days between two dates but it does not include both dates . It just gives the difference. In order to include both dates,I need to add one day more to the results. but I am not able to add that as my both date colums are of type date.
Select Case When DATEDIFF(d,DateFrom ,DateTo) is null
Then DATEDIFF(d,DateFrom ,DateTo)
else
DATEDIFF(d,DateFrom,DateTo) + 1
End
From Table
But it is not working
Upvotes: 1
Views: 569
Reputation: 4094
Use DATEADD(day, 1, DateTo)
to add a day to DateTo
.
To include this in your else
: DATEDIFF(d, DateFrom, DATEADD(day, 1, DateTo))
Upvotes: 2