One very common requirement is for the number of days elapsed since a particular Date and Time. In C# this can be accomplished through the use of the TimeSpan class.
The easiest way to create a TimeSpan is like this:
[source:c#]TimeSpan tsMySpan = DateTime.Now.Subtract( dtCompareTime );
// The number of days elapsed can be accessed like this:
// tsMySpan.Days
[/source]
Tags: C#, General Programming, programming