Date comparison

  • Thread starter Thread starter john sutor
  • Start date Start date
J

john sutor

Does anyone know how to take 2 dates (6/14/04 and 12/12/04) and compare them
to find out what the difference is and if one is so many months ahead of the
other?
 
Hi, john

you might want to use methods and properties of DateTime and related
TimeSpan structures. You can use Parse method to get DateTime and Subtract
method to get difference.

HTH
Alex
 
john sutor said:
Does anyone know how to take 2 dates (6/14/04 and 12/12/04) and compare them
to find out what the difference is and if one is so many months ahead of the
other?

Assuming you've got both of them as DateTimes already (eg date1 and
date2) you can use:

TimeSpan ts = date1-date2;

and look at that timespan for the difference between them.
 
Back
Top