Get the number of days between two DateTimes

8 January, 2005 (16:39) | .NET Code Related

Calculate the number of days between two dates seems really simple, but there are some exceptions. The simplest idea is to substract two DateTime and get the number of days in the resulting TimeSpan. The method doesn’t work when the two dates are set with different year or the number of hour are less than 24 (consider 1/7/2005 10:00PM and 1/8/2005 8:00AM).

Read More

Write a comment