G Grey Mar 9, 2004 #1 I need to compare two dates which one date is 4 days earlier than other date or I can customise the dates comparison difference. How to do it in C#?? Million Thanks
I need to compare two dates which one date is 4 days earlier than other date or I can customise the dates comparison difference. How to do it in C#?? Million Thanks
M Morten Wennevik Mar 9, 2004 #2 Hi Grey, You use a TimeSpan for time comparison. TimeSpan t = Date2 - Date1; The TimeSpan class contains any number of different ways to show the difference, including TotalDays, TotalSeconds, or as a combination of Hours, Seconds, and so on.
Hi Grey, You use a TimeSpan for time comparison. TimeSpan t = Date2 - Date1; The TimeSpan class contains any number of different ways to show the difference, including TotalDays, TotalSeconds, or as a combination of Hours, Seconds, and so on.
J Jon Skeet [C# MVP] Mar 9, 2004 #3 Grey said: I need to compare two dates which one date is 4 days earlier than other date or I can customise the dates comparison difference. How to do it in C#?? Click to expand... Use the overloaded subtraction operator: DateTime d1 = ...; DateTime d2 = ...; TimeSpan difference = d1-d2; then look at the information in the TimeSpan.
Grey said: I need to compare two dates which one date is 4 days earlier than other date or I can customise the dates comparison difference. How to do it in C#?? Click to expand... Use the overloaded subtraction operator: DateTime d1 = ...; DateTime d2 = ...; TimeSpan difference = d1-d2; then look at the information in the TimeSpan.