There often is a debate on time (hours) when it comes to counting days between two dates. The responses to the question and their comments show no exception.
If performance is not a concern, I would strongly recommend documenting your calculation through intermediate conversions. For example, (EndDate - StartDate).Days
is unintuitive because rounding will depend on the hour component of StartDate
and EndDate
.
(EndDate - StartDate).TotalDays
.(EndDate.Date - StartDate.Date).Days
(EndDate.Date - StartDate.Date).Days + 1