View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Helmut Meukel Helmut Meukel is offline
external usenet poster
 
Posts: 49
Default use Excel Now() in VBA

"Peter T" <peter_t@discussions schrieb im Newsbeitrag
...

FWIW Now() normally gets coerced to one second in cells due to the Date type
conversion. However it's actual resolution is to 1/100 sec (at least in my
light testing) so maybe simply -
dim x as double
x = [now()]



Wrong, dead wrong.

Try the same in VB6:
Time() and Now() don't return any fractions of a second.
Time() and Now() use identical code in VB6 and VBA because
it's in the very same DLL: MSVBVM60.DLL

The date data type is internally a double, where the integer part
is the day - starting with 12/30/1899 as day 0 -
and the fractional part is the time - starting at midnight with .0000
Thus .25 is 6:00 AM, .75 is 6:00 PM
Being internally a double, a date data type could hold fractions of
seconds.

The Excel spreadsheet function Now() has the same name as the
VBA function but is more accurate.
If you use the brackets VBA will use the excel function instead of
its own function.
Excel has it's own date/time functions because they were first there.
VBA was added to Excel with Excel 95.

Helmut.