Here you are
static void Main(string[] args)
{
Console.WriteLine(GetDifferenceDate(new DateTime(2008, 11, 25, 10, 30, 2),
new DateTime(2008, 6, 2, 6, 3, 5)));
}
static string GetDifferenceDate(DateTime date1, DateTime date2)
{
if (DateTime.Compare(date1, date2) >= 0)
{
TimeSpan ts = date1.Subtract(date2);
return string.Format("{0} days, {1} hours, {2} minutes, {3} seconds",
ts.Days, ts.Hours, ts.Minutes, ts.Seconds);
}
else
return "Not valid";
}
Ramy Mahrous
Postaholic
2,196 posts since Aug 2006
Reputation Points: 480
Solved Threads: 276
You're welcome, hope it helped!
Please mark your thread solved if it been.
Ramy Mahrous
Postaholic
2,196 posts since Aug 2006
Reputation Points: 480
Solved Threads: 276