compare 2 datetime and get hours
-
first thanks for evryone help others in this website i would like to compare between tow datetime and get the deffrance between them in hours example in parking we get the entrance datetime and leave datetime i want to compare tow datetime and get the real hours of parking
MD_NADA
-
first thanks for evryone help others in this website i would like to compare between tow datetime and get the deffrance between them in hours example in parking we get the entrance datetime and leave datetime i want to compare tow datetime and get the real hours of parking
MD_NADA
-
first thanks for evryone help others in this website i would like to compare between tow datetime and get the deffrance between them in hours example in parking we get the entrance datetime and leave datetime i want to compare tow datetime and get the real hours of parking
MD_NADA
You should look into the TimeSpan object.
TimeSpan timeSpan = DateTime.Now.Subtract(new DateTime(2008, 10, 3));
To get the whole number of hours, its as simple as
int hours = timeSpan.Hours
If you want to get the total hours,double totalHours = timeSpan.TotalHours
If you're unclear on any of this I recommend taking a look at the documentation or doing a google search on System.TimeSpan