#1   Report Post  
Art
 
Posts: n/a
Default Calculate Duration.

Need Help..

I would like to subtract the end time(hh:mm:ss) from the start
time(hh:mm:ss) to get the duration (HH:MM:SS) of how long a job took to
process.

Thanks.

  #3   Report Post  
William
 
Posts: n/a
Default

Hi Art

Sub test()
Dim t As Date, tt As Date
t = Now
'Your code
tt = Now
MsgBox Format((tt - t), "hh:mm:ss")
End Sub
--


XL2003
Regards

William



"Art" wrote in message
...
Need Help..

I would like to subtract the end time(hh:mm:ss) from the start
time(hh:mm:ss) to get the duration (HH:MM:SS) of how long a job took to
process.

Thanks.



  #4   Report Post  
Art
 
Posts: n/a
Default

Thank you Dodo & William

"Art" wrote:

Need Help..

I would like to subtract the end time(hh:mm:ss) from the start
time(hh:mm:ss) to get the duration (HH:MM:SS) of how long a job took to
process.

Thanks.

  #5   Report Post  
Art
 
Posts: n/a
Default

Dodo & William

I have encountered this error. Could you tell me what I'm missing.

c3 = 22:47:00
c2 = 00:01:00

answer: ##############

I only get the above answer when using the midnight time.





"Art" wrote:

Thank you Dodo & William

"Art" wrote:

Need Help..

I would like to subtract the end time(hh:mm:ss) from the start
time(hh:mm:ss) to get the duration (HH:MM:SS) of how long a job took to
process.

Thanks.



  #6   Report Post  
Dave Peterson
 
Posts: n/a
Default

Did you use:
=c2-c3

If you did, then when excel sees negative times (or dates), it shows them as
####'s.

You can avoid this by using the 1904 base date system.

Tools|Options|calculation tab is where you'd toggle this.

But if you have any dates in that workbook, they'll change by 4 years and one
day.

If c2 is the following day, you could do this:

=c2-c3+if(c2<c3,24,0)
or shorter
=c2-c3+(c2<c3)

A more robust way would be to enter both the date and time in each cell.

Art wrote:

Dodo & William

I have encountered this error. Could you tell me what I'm missing.

c3 = 22:47:00
c2 = 00:01:00

answer: ##############

I only get the above answer when using the midnight time.



"Art" wrote:

Thank you Dodo & William

"Art" wrote:

Need Help..

I would like to subtract the end time(hh:mm:ss) from the start
time(hh:mm:ss) to get the duration (HH:MM:SS) of how long a job took to
process.

Thanks.


--

Dave Peterson
  #7   Report Post  
Art
 
Posts: n/a
Default

Thanks Dave that did it..

"Dave Peterson" wrote:

Did you use:
=c2-c3

If you did, then when excel sees negative times (or dates), it shows them as
####'s.

You can avoid this by using the 1904 base date system.

Tools|Options|calculation tab is where you'd toggle this.

But if you have any dates in that workbook, they'll change by 4 years and one
day.

If c2 is the following day, you could do this:

=c2-c3+if(c2<c3,24,0)
or shorter
=c2-c3+(c2<c3)

A more robust way would be to enter both the date and time in each cell.

Art wrote:

Dodo & William

I have encountered this error. Could you tell me what I'm missing.

c3 = 22:47:00
c2 = 00:01:00

answer: ##############

I only get the above answer when using the midnight time.



"Art" wrote:

Thank you Dodo & William

"Art" wrote:

Need Help..

I would like to subtract the end time(hh:mm:ss) from the start
time(hh:mm:ss) to get the duration (HH:MM:SS) of how long a job took to
process.

Thanks.


--

Dave Peterson

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
How do I calculate duration between two dates and times in excel? Robin CSM002 Excel Discussion (Misc queries) 3 May 13th 23 07:42 PM
Duration citizens1stbank Excel Discussion (Misc queries) 0 July 15th 05 06:23 PM
formula to calculate # of days between dates, excluding holidays abs2299 Excel Discussion (Misc queries) 8 March 3rd 05 02:21 AM
how do i calculate minutes between two times? Ron Excel Discussion (Misc queries) 5 February 2nd 05 01:39 AM
Not able to calculate. mark_kramarczyk Excel Worksheet Functions 1 December 29th 04 08:55 PM


All times are GMT +1. The time now is 06:27 PM.

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

About Us

"It's about Microsoft Excel"