Formula for calculating elapsed time between two cells that have full date and time?

blemon

New Member
Joined
Apr 16, 2021
Messages
7
Hello,
I tried to search the forum for this issue but I wasn't able to find anything for this specific issue (unless I was searching the wrong term). Trying to track late arrivals for appointments.

I have two cells:

1623517348130.png


And in the third column, I'd like elapsed time. I get the #VALUE! error for any formula I try, (have tried INT, DATETIME, and even CONCACTENATE to see if I could split the cells up and others I can't remember at the moment), and I've also tried different formats of the cells to see if it's just a format issue. Nothing works.
Also, does the fact that I am pulling the data from another sheet have any effect on this?

Can anyone help me, pls?
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
are the cells formatted as DATE/TIME or are they text
if you change the format to General - do you just get a number returned
IF not - then they are text format and need to be changed to date/time
You could use DATA > Text to Columns , often that will change a text date time to real dates
otherwise
=DATEVALUE(LEFT(B2,10))+TIMEVALUE(RIGHT(B2,8))
to change the value in B2 to a real date
 
Upvote 0
Hi Blemon,

The dates are left aligned which suggests they're text. To convert to a date format use DATEVALUE and TEXTVALUE. I'm assuming you want elaped in hours and minutes so remember if the elapsed time exceeds 24 hours you'll need to Format, Custom [h]:mm

If the time is negative you will see hash signs.

Blemon.xlsx
BCD
1Appt TimeTime InDifference
23-Jun-21 04:30 PM4-Jun-21 03:25 PM22:55
34-Jun-21 03:25 PM4-Jun-21 05:14 PM01:49
44-Jun-21 03:25 PM10-Jun-21 05:14 PM145:49
54-Jun-21 03:25 PM4-Jun-21 03:24 PM################
64-Jun-21 03:25 PM5-Jun-21 03:25 PM24:00
Sheet1 (2)
Cell Formulas
RangeFormula
D2:D6D2=(DATEVALUE(C2)+TIMEVALUE(C2))-(DATEVALUE(B2)+TIMEVALUE(B2))
 
Upvote 0
are the cells formatted as DATE/TIME or are they text
if you change the format to General - do you just get a number returned
IF not - then they are text format and need to be changed to date/time
You could use DATA > Text to Columns , often that will change a text date time to real dates
otherwise
=DATEVALUE(LEFT(B2,10))+TIMEVALUE(RIGHT(B2,8))
to change the value in B2 to a real date
thank you!
 
Upvote 0
Hi Blemon,

The dates are left aligned which suggests they're text. To convert to a date format use DATEVALUE and TEXTVALUE. I'm assuming you want elaped in hours and minutes so remember if the elapsed time exceeds 24 hours you'll need to Format, Custom [h]:mm

If the time is negative you will see hash signs.

Blemon.xlsx
BCD
1Appt TimeTime InDifference
23-Jun-21 04:30 PM4-Jun-21 03:25 PM22:55
34-Jun-21 03:25 PM4-Jun-21 05:14 PM01:49
44-Jun-21 03:25 PM10-Jun-21 05:14 PM145:49
54-Jun-21 03:25 PM4-Jun-21 03:24 PM################
64-Jun-21 03:25 PM5-Jun-21 03:25 PM24:00
Sheet1 (2)
Cell Formulas
RangeFormula
D2:D6D2=(DATEVALUE(C2)+TIMEVALUE(C2))-(DATEVALUE(B2)+TIMEVALUE(B2))
thank you!!
 
Upvote 0
Actually, if you use just
Excel Formula:
=C2-B2
you will get the desired result even though the dates/times are entered as text.
 
Upvote 0
Hi Blemon,

You messaged me you were still getting an error and emailed me the sheet but it works OK. I just copied the formula down and added the same formula in column E with it formatted as Custom [hh]:mm in case the elapsed if ever greater than 24 hours.

The only thing I can think is that your Region does not recognise the date and time format of the text. What Region do you have and do you normally see am and pm on times?

Cell Formulas
RangeFormula
B1:C12B1='late shipment data'!B1
D2:D12D2=(DATEVALUE(C2)+TIMEVALUE(C2))-(DATEVALUE(B2)+TIMEVALUE(B2))
E2:E12E2=(DATEVALUE(C2)+TIMEVALUE(C2))-(DATEVALUE(B2)+TIMEVALUE(B2))
 
Upvote 0
Upvote 0
Hi Blemon,

I'm intrigued to know if you ever tracked down the cause of your challenge and found an answer?
 
Upvote 0

Forum statistics

Threads
1,223,231
Messages
6,170,885
Members
452,364
Latest member
springate

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