Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default 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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default 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
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default 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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,202
Default 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.
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default 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





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default 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



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default 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





  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default 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


  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default 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







  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default 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


  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default 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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
A question of time Marsh New Users to Excel 1 February 2nd 10 08:23 PM
Time Question...is this possible? mileslit Excel Discussion (Misc queries) 1 September 8th 05 01:36 AM
Time Question SU Excel Worksheet Functions 2 August 1st 05 12:20 PM
Time question Stuart[_21_] Excel Programming 4 March 29th 05 05:05 PM
Time Question Kelly Thompson Excel Discussion (Misc queries) 8 December 30th 04 10:35 PM


All times are GMT +1. The time now is 09:27 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"