2
Answers

manipulating time in C#

John

John

16y
3.1k
1

I'm trying to write a simple application which will calculate hours within given time-spans to calculate total time worked in a day for my dad. I need to be able to determine how many hours between start and lunch, how many hours between end of lunch and end of day, and then output those hours.  for example:

given a 6:00 am start time and a 11:00 am lunch time, there's 5 hours. return from lunch at 11:30 am and end day at 2:30 pm for 3 hours. add those together, it's 8 hours worked.

I thought it would be simple to do in code, but i'm having a heck of a time figuring this out.  I've tried timespan, but I get type errors. I've tried datetimeconverter but i'm getting syntax errors.  I thought I could get around the type errors by creating masked text boxes with a mask of Military time (24:00) but it's still reading it as type string.

any suggestions to point me in the right direction would be greatly appreciated. I don't want anyone to have to write it all for me, as I'm trying to learn it all and copying code is a not a good way to learn, but if someone can tell me where I'm going wrong, I would appreciate it. Thanks!

Answers (2)