calculating time

  • Thread starter Thread starter Dennis D.
  • Start date Start date
D

Dennis D.

If the input time (not the system time) in a textbox is 16:00 or 4 PM how do
I subtract 15 minutes and get 3:45 PM?

If the input time is 12:15 AM how do I subtract 30 minutes and get 11:45 PM?

As a side note: I began by parsing 16:00 and using timeserial() to produce
4:00 PM.

My output textboxes should read 3:45 PM and 11:45 PM respectively.

A simple description will do fine. I can write the code.

Thanks,

D.,
http://www.dennisys.com/
 
Dennis D. said:
If the input time (not the system time) in a textbox is 16:00 or 4 PM
how do I subtract 15 minutes and get 3:45 PM?

If the input time is 12:15 AM how do I subtract 30 minutes and get
11:45 PM?

As a side note: I began by parsing 16:00 and using timeserial() to
produce 4:00 PM.

My output textboxes should read 3:45 PM and 11:45 PM respectively.

A simple description will do fine. I can write the code.

- Use Date.Parse or Date.ParseExact to convert from a string to a Date
- Use the methods of the Date object to add/subtract timespans
- Use the Date's ToString method to convert back to a string


--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
 
Convert to a DateTime object and use some of the built-in methods for your
calculation, such as the Subtract method using a TimeSpan.
 
Back
Top