subtracting time

plgii

Registered User.
Local time
Today, 02:29
Joined
Apr 13, 2006
Messages
15
I have 2 textboxes one has military time entered by user. I want to subtract 2hours from this entry and place it into textbox2...
so if user enters 13:00 in Textbox1, how can I get Textbox2 to show 11:00?

I have tried several calcs, but can't seem to get it right.
 
will You also want to handle 13:45 and other similar times with minutes?
 
Sounds like your question is with the math, not the displaying of the results.

Therefore,
the DateAdd() function will let you subtract 2 hours without worrying about crossing a boundary. You may then need to Format() the result to get your military time.

James
 
I was able to get it with:
At least it seems to work correctly

Me.Text8 = (Me.Text0 - 0.083333332)
then I can do this:
If Time() >= (Me.Text8) Then

here is where I then change background color to red to alert user
 
adding a ":" in between the numbers isn't actually strictly military, it is just 1300 for example.

The data add function will work, but using the example above, it can be kept alot simpler by the following code:

Code:
Dim numtime as integer
numtime = me.form.text8
text0 = numtime - 200

Of course this is as simple as it gets. If you are incorporating dates etc in the databse and forinstance the time is 0100 and you want the date to change to the previos day when you minus the 1 hour, then you will need to look further at the date add function
 

Users who are viewing this thread

Back
Top Bottom