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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add hours to Time() in VBA

Status
Not open for further replies.

insanity2

Technical User
Feb 7, 2009
4
ES
This is driving me nuts or maybe it can't be done. I created a form with a labelbox called Clock that gives the current time as described in thread705-1282461. I want to create a clock with UTC time next to it.

How can I subtract 1 hour from the Time() function?
 
Did you try DateAdd?

[tt]dt = Time
debug.print dt, dateadd("h", -1, dt)[/tt]

Roy-Vidar
 
Didn't work. Still gives Run-time Error 424. Object required.

Could it be I can only use the "On Timer" event for just one caption on the form?
 
Correction...I got the second clock to work. I named the label wrong, but your suggestion didn't subtract the hour off.
 
AND it must be my goofy Vista machine, but this code worked finally:

ZuluClock.Caption = time + TimeSerial(-1, 0, 0)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top