View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tim Zych Tim Zych is offline
external usenet poster
 
Posts: 389
Default Time bug, anyone know why?

Here is one workaround using DateAdd

Dim dt As Date
dt = #1/1/2008 12:55:00 PM#
MsgBox DateAdd("h", 1, dt)

--
Tim Zych
http://www.higherdata.com
Workbook Compare - Excel data comparison
Free & Pro versions


"Mark Stephens" wrote in message
...
Hi all,

I am trying to increment a time for a shceduling feature in my program. I
want to increase the time by 1 hour each time i click a button. Here's the
methodology:

1. Read the cell containing the system date and time

2. Add to the number (1/24)

3. Update the button caption


It's pretty simple really but what happens is that instead of increasing
the time by an hour as intended it increases it by 1 hour and one minute!
Frustrating and annoying. Adjusting the increment slightly doesn't seem to
have much effect at all. I have done some searching on google in this
newsgroup and whilst i have found some workarounds such as using ceiling
or floor or rounding, noone hseems to have addressed the basic issue which
is why the time concept of 1/24 for an hour doesn't work; I suppose it
could be somethibng to do with rounding (is vba rounding the decimal up to
the next one minute incrememtn automatically?) seems strange any
suggestions/explanations/workarounds gratwefully received.

Thanks and regards, Mark