ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   time question (https://www.excelbanter.com/excel-programming/395328-time-question.html)

Gary Keramidas

time question
 
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?

--



Gary



Ron Rosenfeld

time question
 
On Sun, 12 Aug 2007 11:56:15 -0400, "Gary Keramidas" <GKeramidasATmsn.com
wrote:

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 [s].000


--ron

Gary Keramidas

time question
 

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" wrote in message
...
On Sun, 12 Aug 2007 11:56:15 -0400, "Gary Keramidas" <GKeramidasATmsn.com
wrote:

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 [s].000


--ron




Rick Rothstein \(MVP - VB\)

time question
 
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 [s].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.

Gary Keramidas

time question
 
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)" wrote in message
...
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 [s].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




Gary Keramidas

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

--


Gary


"Rick Rothstein (MVP - VB)" wrote in message
...
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 [s].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




Tim Williams

time question
 
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" <GKeramidasATmsn.com wrote in message
...
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)" wrote in
message ...
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 [s].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






Peter T

time question
 
"Rick Rothstein (MVP - VB)" wrote in
message ...


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"), "[s].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



Gary Keramidas

time question
 
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" <timjwilliams at gmail dot com wrote in message
...
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" <GKeramidasATmsn.com wrote in message
...
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)" wrote in
message ...
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 [s].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








Ron Rosenfeld

time question
 
On Sun, 12 Aug 2007 15:51:12 -0400, "Gary Keramidas" <GKeramidasATmsn.com
wrote:


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 [s].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

Gary Keramidas

time question
 
ok, thanks. that'll be good enough. i figured it was some excel limitation.

--


Gary


"Ron Rosenfeld" wrote in message
...
On Sun, 12 Aug 2007 15:51:12 -0400, "Gary Keramidas" <GKeramidasATmsn.com
wrote:


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 [s].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





All times are GMT +1. The time now is 03:46 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com