Link to home
Start Free TrialLog in
Avatar of CipherIS
CipherISFlag for United States of America

asked on

C# Calculate the duration between two hours

I need to calculate the duration between two hours.  User is entering Start Time and End Time.  As an example:

Start Time = 12:00 PM
End Time = 2:00 PM

Duration = 2 Hrs

Any ideas?
ASKER CERTIFIED SOLUTION
Avatar of p_davis
p_davis

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of CipherIS

ASKER

how do i get the subtract?  They are both in text fields?
figured it out - thx
Avatar of p_davis
p_davis

DateTime.Parse(StartTime); or try parse should give you what you want..

you will probably want to do some bad format testing before you try to parse but try parse will help you do that
DateTime.TryParse