Calculating Time- Formula Error?

DougStroud

Well-known Member
Joined
Aug 16, 2005
Messages
2,968
I am trying to do a simple timesheet calculating hours worked:
10:35a-5:15p
Formula: b1-a1

A1 and B1 are formatted as time with hours, minutes
C1 is formatted as time in custom: h:mm

Results are- #Value !
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
I found one work around- if I enter 10:35 am and 5:15 pm it then resolves. But how persnickety is this, rather than a simple "a" or "p"?
 
Upvote 0
But how persnickety is this, rather than a simple "a" or "p"?

When would you ever say when you are talking to someone about time 10:35a rather than 10:35am? 10:35a just isn't way of a common way of referring to time so why would Excel treat it as a time rather than text?

If you have a lot to change use the REPLACE function.
 
Upvote 0
It's not about "a" vs "am", it's the space between the digit and the letter. Excel does understand "10:35 a".

Try using this formula:

=SUBSTITUTE(SUBSTITUTE(UPPER(B1),"P"," P"),"A"," A")-SUBSTITUTE(SUBSTITUTE(UPPER(A1),"P"," P"),"A"," A")
 
Upvote 0

Forum statistics

Threads
1,214,812
Messages
6,121,699
Members
449,048
Latest member
81jamesacct

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