Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the hour and minutes difference between 2 datetimestamp in Excel?

Tags:

Suppose I have 2 timestamp dates:

  1. 2/24/2010 1:05:15 AM
  2. 2/25/2010 4:05:17 AM

Can anyone please advise what function should I use in Excel to get the difference in hours and minutes?

Thanks.

like image 845
jl. Avatar asked Feb 24 '10 09:02

jl.


People also ask

How do you find the difference between two dates in hours and minutes?

get time() -startDate. gettime())/1000; Log. d("App","difference in hour is"+diff/1000/60/60); Mins = diff/1000/60; Seconds = diff/1000; Using this code I'm getting hours as a correct value.

How do I calculate the time between two dates in Excel?

In a new cell, type in =DATEDIF(A1,B1,”Y”). The “Y” signifies that you'd like the information reported in years. This will give you the number of years between the two dates. To find the number of months or days between two dates, type into a new cell: =DATEDIF(A1,B1,”M”) for months or =DATEDIF(A1,B1,”D”) for days.


2 Answers

The difference in hours:

=(A2-A1)*24 

The difference in minutes:

=(A2-A1)*24*60 

The difference in hours and minutes:

=TRUNC((A2-A1)*24)      - the hours portion =MOD((A2-A1)*24*60,60)  - the minutes portion 
like image 165
a'r Avatar answered Sep 20 '22 11:09

a'r


this is straight simple in excel and no need to do anything except applying the time format to the cell.

two easy steps:

  1. put the formula: =B2-A2
  2. simply apply the custom format "h:mm" to the cell.
like image 23
omarmallat Avatar answered Sep 23 '22 11:09

omarmallat