HiveBrain v1.2.0
Get Started
← Back to all entries
gotchacsharpCritical

How to calculate difference between two dates (number of days)?

Submitted by: @import:stackoverflow-api··
0
Viewed 0 times
dayshowcalculatebetweendifferencenumbertwodates

Problem

How can one calculate the number of days between two dates in C#?

Solution

Assuming StartDate and EndDate are of type DateTime:

(EndDate - StartDate).TotalDays

Code Snippets

(EndDate - StartDate).TotalDays

Context

Stack Overflow Q#1607336, score: 2654

Revisions (0)

No revisions yet.