time question

  • Thread starter Thread starter Gary Keramidas
  • Start date Start date
G

Gary Keramidas

if i want to time an operation, can i format the result from the start time to the end time in seconds and fractions of a second, rather than just whole seconds?
 
if i want to time an operation, can i format the result from the start time to the end time in seconds and fractions of a second, rather than just whole seconds?

You could format your result as .000


--ron
 
thanks. don't know what i'm doing wrong, but when i set the start time to now,
and the end time to now and then subtract, i get something like this:
8.10185156296939E-05
when i try to format the output like you suggested, i get zeroes.

--


Gary


Ron Rosenfeld said:
if i want to time an operation, can i format the result from the start time to
the end time in seconds and fractions of a second, rather than just whole
seconds?

You could format your result as .000


--ron
 
if i want to time an operation, can i format the result from the start
time to the end time in seconds and fractions of a second, rather than
just whole seconds?

You could format your result as .000


thanks. don't know what i'm doing wrong, but when i set the start time to
now, and the end time to now and then subtract, i get something like this:
8.10185156296939E-05
when i try to format the output like you suggested, i get zeroes.


Well, the format that Ron gave you will only display 3 decimal places, the
number you posted is

0.0000810185156296939

with the power of 10 part multiplied through, which, if you notice, has 4
zeroes after the decimal point. That number, rounded to 3 decimal places is
0.

Rick
 
but it should display 3 or 4 seconds.

how do i get it so i can show how many seconds the routine runs? i have 3
different scenarios, i know which is faster, i'm just looking to time them.

thanks

--


Gary


Rick Rothstein (MVP - VB) said:
if i want to time an operation, can i format the result from the start time
to the end time in seconds and fractions of a second, rather than just whole
seconds?

You could format your result as .000


thanks. don't know what i'm doing wrong, but when i set the start time to
now, and the end time to now and then subtract, i get something like this:
8.10185156296939E-05
when i try to format the output like you suggested, i get zeroes.


Well, the format that Ron gave you will only display 3 decimal places, the
number you posted is

0.0000810185156296939

with the power of 10 part multiplied through, which, if you notice, has 4
zeroes after the decimal point. That number, rounded to 3 decimal places is 0.

Rick
 
i guess this is as close as i can get:
Second(endtime) - Second(starttime)

--


Gary


Rick Rothstein (MVP - VB) said:
if i want to time an operation, can i format the result from the start time
to the end time in seconds and fractions of a second, rather than just whole
seconds?

You could format your result as .000


thanks. don't know what i'm doing wrong, but when i set the start time to
now, and the end time to now and then subtract, i get something like this:
8.10185156296939E-05
when i try to format the output like you suggested, i get zeroes.


Well, the format that Ron gave you will only display 3 decimal places, the
number you posted is

0.0000810185156296939

with the power of 10 part multiplied through, which, if you notice, has 4
zeroes after the decimal point. That number, rounded to 3 decimal places is 0.

Rick
 
Your number 8.10185156296939E-05 most likely represents a fraction of a day.

Try multiplying it by 24*60*60 (# of secs in a day) before formatting or
rounding to 3 dp

I get 6.9999997

Tim

Gary Keramidas said:
but it should display 3 or 4 seconds.

how do i get it so i can show how many seconds the routine runs? i have 3
different scenarios, i know which is faster, i'm just looking to time
them.

thanks

--


Gary


Rick Rothstein (MVP - VB) said:
if i want to time an operation, can i format the result from the start
time to the end time in seconds and fractions of a second, rather than
just whole seconds?

You could format your result as .000

thanks. don't know what i'm doing wrong, but when i set the start time
to now, and the end time to now and then subtract, i get something like
this:
8.10185156296939E-05
when i try to format the output like you suggested, i get zeroes.


Well, the format that Ron gave you will only display 3 decimal places,
the number you posted is

0.0000810185156296939

with the power of 10 part multiplied through, which, if you notice, has 4
zeroes after the decimal point. That number, rounded to 3 decimal places
is 0.

Rick

 
Well, the format that Ron gave you will only display 3 decimal places, the
number you posted is

0.0000810185156296939

Or as a fraction of a day that's almost exactly 7 seconds !

dt = 0.0000810185156296939

MsgBox Format(dt, "s.000") & vbCr & _
Format(Format(dt, "s.000"), ".000") ' 7.000 & 7.000

Debug.Print dt * 24 * 60 * 60 ' 6.99999975040555 seconds

Gary, if you're looking for accuracy of better than 0.5 seconds better to
use an API

Regards,
Peter T
 
thanks, tim.
i was multiplying 1440*60, but didn't understand why i only got whole numbers
when i show the results in the immediate window for the 3 routines, i get:
3.9999996778
6.9999997504
5.9999995166

when i was trying to format to 2 decimal places, i always just got the whole
number
why are the all .999999?
--


Gary


Tim Williams said:
Your number 8.10185156296939E-05 most likely represents a fraction of a day.

Try multiplying it by 24*60*60 (# of secs in a day) before formatting or
rounding to 3 dp

I get 6.9999997

Tim

Gary Keramidas said:
but it should display 3 or 4 seconds.

how do i get it so i can show how many seconds the routine runs? i have 3
different scenarios, i know which is faster, i'm just looking to time them.

thanks

--


Gary


Rick Rothstein (MVP - VB) said:
if i want to time an operation, can i format the result from the start
time to the end time in seconds and fractions of a second, rather than
just whole seconds?

You could format your result as .000

thanks. don't know what i'm doing wrong, but when i set the start time to
now, and the end time to now and then subtract, i get something like this:
8.10185156296939E-05
when i try to format the output like you suggested, i get zeroes.

Well, the format that Ron gave you will only display 3 decimal places, the
number you posted is

0.0000810185156296939

with the power of 10 part multiplied through, which, if you notice, has 4
zeroes after the decimal point. That number, rounded to 3 decimal places is
0.

Rick


 
thanks. don't know what i'm doing wrong, but when i set the start time to now,
and the end time to now and then subtract, i get something like this:
8.10185156296939E-05
when i try to format the output like you suggested, i get zeroes.

When I format your value: 8.10185156296939E-05 as .000 I get 7.000
(seconds)

That is precise to three decimal places, which is as good as you will get using
a time format.

If you want more precision than thousandths of a second is required (and that
might be the case if you have very very accurate time determining techniques),
then you should not be using Excel time format.

Excel stores time as a fraction of a day. So 8.10185156296939E-05 is equal to
6.999999750405550 seconds. Rounded to thousandths of a second, it is 7.000
seconds.
--ron
 
ok, thanks. that'll be good enough. i figured it was some excel limitation.

--


Gary


Ron Rosenfeld said:
thanks. don't know what i'm doing wrong, but when i set the start time to now,
and the end time to now and then subtract, i get something like this:
8.10185156296939E-05
when i try to format the output like you suggested, i get zeroes.

When I format your value: 8.10185156296939E-05 as .000 I get 7.000
(seconds)

That is precise to three decimal places, which is as good as you will get
using
a time format.

If you want more precision than thousandths of a second is required (and that
might be the case if you have very very accurate time determining techniques),
then you should not be using Excel time format.

Excel stores time as a fraction of a day. So 8.10185156296939E-05 is equal to
6.999999750405550 seconds. Rounded to thousandths of a second, it is 7.000
seconds.
--ron
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top