Sunday, October 4, 2009

Difference between two dates in C#

public int GetTotalDays(DateTime startedDateTime)

{

//get the current date

DateTime nowDate = System.DateTime.Now;

//use timespan to get the number of days

System.TimeSpan span = nowDate - startedDateTime;

int days = (int)span.TotalDays;

return days;

}

No comments:

Post a Comment