Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel,microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Calculating Time Elapsed in Excel

Hi Everyone,

How can I calculate the time elapsed between two given times?
For example if I input initial time and date as 20:00 on 03 Jan 06 and
final time and date as 05:00 on 05 Jan 06, I want to calculate the
number of hours elapsed. Moreover I am interested in whole numbers i.e.
8 hours and 31 minutes should round to 9 hours and 8 hours and 29
minutes should round to 8 hours. I need to multiply this time elapsed
with another constant quantity?

Any help would be appreciated.

regards

  #2   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.excel
external usenet poster
 
Posts: 4,339
Default Calculating Time Elapsed in Excel

Hi,
Assuming dates are held in format dd/mm/yyyy HH:MM then simple
subtract two dates and multiply by 24.

e.g in c1 put = INT((B1-A1)*24+0.5)

03/06/2006 20:00 (A1)

05/06/2006 20:29 (B1)

C1=48

HTH

" wrote:

Hi Everyone,

How can I calculate the time elapsed between two given times?
For example if I input initial time and date as 20:00 on 03 Jan 06 and
final time and date as 05:00 on 05 Jan 06, I want to calculate the
number of hours elapsed. Moreover I am interested in whole numbers i.e.
8 hours and 31 minutes should round to 9 hours and 8 hours and 29
minutes should round to 8 hours. I need to multiply this time elapsed
with another constant quantity?

Any help would be appreciated.

regards


  #3   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.excel
external usenet poster
 
Posts: 3
Default Calculating Time Elapsed in Excel

Thanks Toppers.

I have copied the formula to other cells in the column. The only
problem is that when there is nothing in the first two columns, I get
0.00. in the third column.
Is it possible that these cells remain blank untill I enter dates/times
in the first two columns?

Thanks

  #4   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.excel
external usenet poster
 
Posts: 4,339
Default Calculating Time Elapsed in Excel

Hi,
Ig I understand correctly, in third column you could put:

=IF(Sum(a2:b2)=0, " ", sum(a2:b2))

" wrote:

Thanks Toppers.

I have copied the formula to other cells in the column. The only
problem is that when there is nothing in the first two columns, I get
0.00. in the third column.
Is it possible that these cells remain blank untill I enter dates/times
in the first two columns?

Thanks


  #5   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.excel
external usenet poster
 
Posts: 4,339
Default Calculating Time Elapsed in Excel

Hi,
Sorry, ignore my previous reply!

Should be:

=IF(OR(A1="",B1=""),"",INT((B1-A1)*24+0.5))


"Toppers" wrote:

Hi,
Assuming dates are held in format dd/mm/yyyy HH:MM then simple
subtract two dates and multiply by 24.

e.g in c1 put = INT((B1-A1)*24+0.5)

03/06/2006 20:00 (A1)

05/06/2006 20:29 (B1)

C1=48

HTH

" wrote:

Hi Everyone,

How can I calculate the time elapsed between two given times?
For example if I input initial time and date as 20:00 on 03 Jan 06 and
final time and date as 05:00 on 05 Jan 06, I want to calculate the
number of hours elapsed. Moreover I am interested in whole numbers i.e.
8 hours and 31 minutes should round to 9 hours and 8 hours and 29
minutes should round to 8 hours. I need to multiply this time elapsed
with another constant quantity?

Any help would be appreciated.

regards




  #6   Report Post  
Posted to microsoft.public.excel,microsoft.public.excel.programming
external usenet poster
 
Posts: 139
Default Calculating Time Elapsed in Excel

Per :
How can I calculate the time elapsed between two given times?
For example if I input initial time and date as 20:00 on 03 Jan 06 and
final time and date as 05:00 on 05 Jan 06,


How about this: create a macro to do the heavy lifting and then invoke the
macro in the cell that you want the calc result in.

The macro would look something like this (subject to your modifying the
rounding/truncation):
------------------------------------------------------------------------
Function HoursDiff(ByVal theBeginDateTime As Variant, ByVal theEndDateTime As
Variant) As Long

'PURPOSE: To calculate the difference in hours between two Date/Time values.
'ACCEPTS: - Beginning Date/Time value
' - Ending Date/TimeValue
'RETURNS: Number of hours between the two values
'
Dim myDiff As Long

myDiff = DateDiff("n", theBeginDateTime, theEndDateTime)
myDiff = myDiff / 60

HoursDiff = myDiff

End Function
---------------------------------------------------------------------------

Then, in the cell you want the result in, you put something this into cell A1:

=HoursDiff(E1, F1)

Then type "01/03/2005 20:00:00" into cell E1 and type "01/05/2005 17:00" into
cell F1 and then "45" should magically appear in cell A1.

I could email you the sample spreadsheet - but with one caveat: I don't know
beans about Excel and once I created the function I couldn't find it again...
it's there because I'm getting the results I expect...it's just hiding somewhere
and anybody who knows Excel could probably find it.
--
PeteCresswell
  #7   Report Post  
Posted to microsoft.public.excel,microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Calculating Time Elapsed in Excel

Thanks Pete but I will stick to Toppers solution at this time. Its
doing what I want. One thing that I need now is to lock the column
containing the formula so the user cannot change it . I want the user
to enter the date and time but prevent him from deleting the formula
accidentally.

Thanks and regards

  #8   Report Post  
Posted to microsoft.public.excel,microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Calculating Time Elapsed in Excel

Thanks Pete but I will stick to Toppers solution at this time. Its
doing what I want. One thing that I need now is to lock the column
containing the formula so the user cannot change it . I want the user
to enter the date and time but prevent him from deleting the formula
accidentally.

Thanks and regards

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Calculating Time Elapsed in Excel


Hi

Why don't you just do the following
Sub main()

Cells(1, 1).NumberFormat = "[h]:mm:ss;@"
Cells(1, 1) = Format(Time, "hh:mm:ss")

Call Functioname(x, y, z)

Cells(2, 1).NumberFormat = "[h]:mm:ss;@"
Cells(2, 1) = Format(Time, "hh:mm:ss")

Timee = Cells(2, 1) - Cells(1, 1)
Cells(2, 1).NumberFormat = "[h]:mm:ss;@"
Cells(3, 1) = Format(Timee, "hh:mm:ss")


End Sub


--
karnak
------------------------------------------------------------------------
karnak's Profile: http://www.excelforum.com/member.php...o&userid=28918
View this thread: http://www.excelforum.com/showthread...hreadid=502368

  #11   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.excel
external usenet poster
 
Posts: 1
Default Calculating Time Elapsed in Excel

Try using the cell format [h]. You may need to make it in the custom option
in format cells.

" wrote:

Hi Everyone,

How can I calculate the time elapsed between two given times?
For example if I input initial time and date as 20:00 on 03 Jan 06 and
final time and date as 05:00 on 05 Jan 06, I want to calculate the
number of hours elapsed. Moreover I am interested in whole numbers i.e.
8 hours and 31 minutes should round to 9 hours and 8 hours and 29
minutes should round to 8 hours. I need to multiply this time elapsed
with another constant quantity?

Any help would be appreciated.

regards


  #12   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.excel
external usenet poster
 
Posts: 3
Default Calculating Time Elapsed in Excel

Thanks for the help guys.

regards

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
Calculating Elapsed Time Rosemary Excel Worksheet Functions 2 March 23rd 09 03:23 PM
Calculating elapsed time tele2002 Excel Discussion (Misc queries) 2 December 22nd 05 05:47 PM
Calculating Time elapsed bhomer Excel Worksheet Functions 1 November 21st 05 01:16 PM
Calculating elapsed time andoh Excel Worksheet Functions 5 November 17th 05 11:31 AM
Calculating a rate for elapsed time? Keith Excel Discussion (Misc queries) 8 May 18th 05 09:14 PM


All times are GMT +1. The time now is 02:04 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"