Difference between two dates in hours

smide

Board Regular
Joined
Dec 20, 2015
Messages
164
Office Version
  1. 2016
Platform
  1. Windows
Hello.


In columns B and C (B2:B600, C2:C600) I'm receiving dates (with hours and minutes) in rather strange form - without current year?


For example in cell B2: 12.02. 19:07


Explanation: 12 - day, 02 - month (February), then after 02. there is a one space, 19 - hours, 07 - minutes


In cell C2: 14.02. 11:05


I need to calculate difference between dates C2-B2 in hours.


Note: all those dates have the same year 2018

Example:

[TABLE="class: grid, width: 500, align: center"]
<tbody>[TR]
[TD="align: center"][/TD]
[TD="align: center"]A[/TD]
[TD="align: center"]B[/TD]
[TD="align: center"]C[/TD]
[TD="align: center"]D[/TD]
[/TR]
[TR]
[TD="align: center"]1[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]2[/TD]
[TD="align: center"][/TD]
[TD="align: center"]12.02. 19:07[/TD]
[TD="align: center"]14.02. 11:05[/TD]
[TD="align: center"] C2-B2 (in hours)[/TD]
[/TR]
[TR]
[TD="align: center"]3[/TD]
[TD="align: center"][/TD]
[TD="align: center"]....[/TD]
[TD="align: center"]....[/TD]
[TD="align: center"]....[/TD]
[/TR]
[TR]
[TD="align: center"]4[/TD]
[TD="align: center"][/TD]
[TD="align: center"]....[/TD]
[TD="align: center"]....[/TD]
[TD="align: center"]....[/TD]
[/TR]
</tbody>[/TABLE]

 
Last edited:

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
you should just parse the text and create dates, then you can add/subtract them... the result will be in days and you can multiply by 24 to get hours....

you need to use functions like MID SEARCH LEFT RIGHT to parse text and then use the date function to create a date with the parsed values

https://www.techonthenet.com/excel/formulas/date.php
 
Last edited:
Upvote 0
Try this in D2:

=(DATE(2018,MID(C2,4,2),LEFT(C2,2))+RIGHT(C2,5)-(DATE(2018,MID(B2,4,2),LEFT(B2,2))+RIGHT(B2,5)))*24

or

=DATE(2018,MID(C5,4,2),LEFT(C5,2))+RIGHT(C5,5)-(DATE(2018,MID(B5,4,2),LEFT(B5,2))+RIGHT(B5,5)) formatted as Custom [h]:mm
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,849
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top