Always Get Better

Never stop looking for ways to improve

April 29th, 2008

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:

TimeSpan tsMySpan = DateTime.Now.Subtract( dtCompareTime );

// The number of days elapsed can be accessed like this:
// tsMySpan.Days

Related posts:

  1. Finding Your Ubuntu Version

  • Mike Wilson (158)
  • Leave a Reply