Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding Time

Status
Not open for further replies.

tenbellies

Programmer
Dec 20, 2002
17
GB
I have a timer to extract some data but once that has finished i need to extract some more data 2hrs after that one has finished. Rather than setting another timer with data input i want to be able to add 2 hrs onto the existing time that the user has said to run the first script. I have tried the following but keep getting rubbish back...

qk = Format$(Text1, "hh:mm")
qk2 = "02:00:00"
qk3 = Format$(qk2, "hh:mm")
qk4 = qk + qk3
Text5 = qk4

Can anyone help?
 
Have a look at the DateAdd() function.

HarleyQuinn
---------------------------------
Help us to help you,
read FAQ222-2244 before posting.
 
Thanks for the tip but still haveing troubel...

the time is in the format hh:mm so if the user inputs a time of 05:00 i need ot to add on 2hrs. i can't get the adddate to work i have it as follows:

DateAdd("h", 2)
can you help further?
 
You need to include the date you wish to add two hours to.
e.g.
Code:
DateAdd("h", 2, YourDate)
Hope this helps

HarleyQuinn
---------------------------------
Help us to help you,
read FAQ222-2244 before posting.
 
i don't have a date only time. I have it sorted now using the folowing...

Dim MyString, LeftString
MyString = Text1
LeftString = Left(MyString, 2)
Dim MyVar
MyVar = Mid(Text1, 3, 6)
timedel = Text5
Label8 = LeftString + timedel & MyVar

i know it's not the best way but it works
 
Glad you got it to work.

The way I would have done it with the DateAdd would be something like:
Code:
Dim MyTime as String
MyTime = Format$(Text1.Text,"hh:mm")
label8.Caption = Format$(DateAdd("h", Text5.Text, MyTime), "hh:mm")
Hope this helps

HarleyQuinn
---------------------------------
Help us to help you,
read FAQ222-2244 before posting.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top