Time not in 24 hour view - excel

I am attempting to sum up hours per day across numerous fields. The issue I am encountering is when the sum passes 24 hour it defaults to 24 hour clock so 01:00:00 for 25 hours when actually I want it to show 25:00:00. Can anyone advise on this please? Many thanks,

Depends how your data is formatted - what happens if you change the custom number format to this:
[h]:mm:ss

The time is stored as a number by Excel and it will only show from 0 to 24 hours. If you format the cell as a number it should be 1.04 which Excel sees as 1.04 days and only uses the .04 when formatted as a time. Add *24 to your calculation and you will get 25.00.
It's a little more tricky to get your desired format hh:mm:as but I'll have a go and get back to you shortly.

Related

Time Difference Excel hh:mm Giving Odd Answer

I am flabbergasted as to what I am doing wrong as I simply want it to show 39:54 (39 hours, 54 minutes). I'm guessing it's something obvious but the formulas I've tried either give me 21:36 (?) or 39.9. 39.9 makes sense as it's 39 hours but the .9 is related to 54 minutes being 90% of 60 minutes.
Any help is much appreciated. Thank you !
You are doing it wrong.
=TEXT(M3-L3,"[hh]:mm")
Excel stores date/time as days and fractions of a day since 1/1/1900 where that date = 1
M3-L3 --> the difference in date/time
To format that result as hours:minutes, you use [hh]:mm
hh rolls over the hours every 24; [hh] will display the cumulative hours.
So, when you calculate (M3-L3) * 24, you are converting the stored value to hours. But [hh]:mm expects the value that you are formatting to be an actual date/time value. Hence the error.
In your second example, where you show the result of (m3-l3)*24 is 39.9; you have converted the time difference to decimal hours. 39.9 is 39 hours + 0.9 hours which is the same as 39 hours 54 minutes (0.9 * 60 minutes = 54 minutes)
You don't need TEXT function. Subtract one time from the another and format the cells with a custom format [h]:mm
(Rant: Excel's date and time formatting capabilities are very limited and difficult to work with - I'm sure it was great in comparison to other spreadsheet systems in the mid-1990s, but Microsoft has always been very conservative about updating Excel's core functionality - so even today, in 2020, Excel does not have a built-in formula function equivalent to DateTime.ParseExact and it ALWAYS prefers local computer settings which is bloody annoying as my computer is set to en-GB (but uses yyyy-MM-dd as my date-format override) so it's impossible to easily parse US-formatted date values, argh) - and there's still no support for consistently parsing ISO 8601 values, which is crazy for 2020.
Anyway - given this backstory on Excel's pathetic date and time formatting and parsing functionality, it's no surprise then that Excel doesn't support formatting hh as "total hours" - it always renders it in Modulo 24 (or Modulo 12 if you specify h)
(I retract the above statement because Ron's answer of [hh]:mm works, but it's still under-documented behaviour as it's not mentioned in Excel's documentation for TEXT() at all)
Assuming that L2 and M2 are being interpreted as Date+Time values correctly (I assume L2 is 2020-01-07 09:55 and M2 is 2020-01-09 01:49- and not 2020-01-07 09:55 and 2020-01-09 01:49 respectively), then try this:
Set N2's formula to = M2 - L2 - this should result in a floating-point Number value that represents the number of days-difference between the two dates.
Format it manually in O2 with this formula
= FLOOR( N2 * 24, 1 ) & ":" & ( ( N2 * 24 ) - TRUNC( N2 * 24 ) * 60 )
Update:
With my apologies to #RonRosenfeld, the examples given in the ExcelJet page do include a mention of using \[ and \] for formatting Elapsed Time values. The example is given as a screenshot which makes it impossible to search for (it's 2020 and search engines still don't do OCR on images - nor do browsers do Find-in-Page for images either). I'll repeat the information in text form so people can grep this answer:
From https://exceljet.net/custom-number-formats
Elapsed time is a special case and needs special handling. By using square brackets, Excel provides a special way to display elapsed hours, minutes, and seconds. The following screen shows how Excel displays elapsed time based on the value in D5, which represents 1.25 days:
A B C
Description Formula Formatted Value
-----------------------------------------------------------------------
1 Example elapsed time (days) =1.25 1.25
2 Elapsed hours (total hours) =TEXT(B1, "[h]") 30
3 Elapsed hours with minutes =TEXT(B1, "[h]:mm") 30:00
4 Elapsed minutes =TEXT(B1, "[m]") 1800
5 Elapsed minutes with seconds =TEXT(B1, "[m]:ss") 1800:00
6 Elapsed seconds =TEXT(B1, "[ss]") 108000
7 Elapsed seconds with milliseconds =TEXT(B1, "[ss].00") 108000.00
I cannot find any authoritative reference in Excel's documentation for the behaviour of [] when formatting numbers as durations - so technically this could be considered undocumented behaviour. That said, it probably is documented in the offline help files of older versions of Excel, I know a lot of useful documentation was lost when Office moved to all-online help between 2003 and 2013, grrrrrr.

Excel units of time conversion

I need to change a value of time from days:hours:minutes, into either hours with a decimal or minutes. My data comes up as 001:05:46 for example. I am having trouble with the leading zeros confusing excel. Any help would be great!
Assuming that your value to parse is formatted in DDD:HH:MM like 001:05:46... There are a lot of ways to do this but here's a simple one. To convert into hours we need to take the days times 24 hours per day, add the hours, and add the minutes times 1 hour per 60 minutes:
=LEFT(A1,3)*24+MID(A1,5,2)+RIGHT(A1,2)/60
To get this value in terms of minutes we multiply by 60 minutes per hour. A possible modification of the original formula to reach this point would be:
=LEFT(A1,3)*24*60+MID(A1,5,2)*60+RIGHT(A1,2)

Converting from [h]:mm:ss

I have a spreadsheet which contains the hours individual employees have worked in a month.
This column is set to a custom format [h]:mm:ss. I want to convert the hours worked into an integer.
I'm using this formula to try and convert the values:
=(HOUR(F4)*60+MINUTE(F4)*60+SECOND(F4))/60
Nothing is coming out as expected, though.
For 159:05:45, I get 20.75, for example.
Can anyone explain what's going on and how to correct this?
Hour * 60 gives you minutes
Minutes * 60 gives you seconds
And you're adding both; which immediately doesn't sound right.
If you want the time in minutes, you can do something like that:
=F4*24*60
And format as number.
Date/time is stored in days. Multiply by 24 to get in terms of hours and by 60 to get minutes.
Use =((TEXT(f4,"[hh]")*60)+MINUTE(f4)+(SECOND(f4)/60))

How should durations of time be displayed in a spreadsheet?

I'm creating a report which display duration of time (in hours) between two points in time.
e.g.
Duration between 10:00 to 13:30 equals 3 hrs 30 minutes
This information is being saved into a spreadsheet (excel) in one "duration" column, titled "Duration (hrs)". The column needs to be sortable to allow sorting by longest duration, etc.
Should this be displayed as 3.5 or 3.30 using a numerical column format? Or as 03:30 using a time format? Is there a standard for this or purely down to preference?
Appreciate your thoughts!
Thanks,
Andy
Note also that if you use "hh:mm" for your time format, that will just give you max 24, so even if it goes over several days, you won't see more than 24 hours. If you want the TOTAL number of hours, use "[hh]:mm" to see e.g. 45:32
I think it's probably just down to preference - either method should work and be sortable
For a time format you can just subtract, e.g.
=B2-A2
or for decimal just multiply by 24
=(B2-A2)*24
Personally I think that time durations should be kept in time format.....

Adding Two Times Up In Excel

I I'm have small headache caused today by excel and the way it takes control of everything. I have two time values I need to add together then divide by a value I got charged for that time to work out how much it cost me an hour.
so say I was charged day on for 12:30:00
on day 2 I was charged for 13:20:00
and day 3 I was charged for 20:30:00
In total it cost me £1000
The calculation would be
£1000 / (12:30:00 + 13:20:00 + 20:30:00 = 46:20:00)
I would guess to get the answer I would
1000 / Sum(12:30:00+13:20:00+20:30:00) = price per hour
But it doesn't...
I guess I need some sort of convert function on the time or to divide it by 24 to get hours but I'm stuck
Help would be hugely appreciated!
Excel represents times as fractional days, so your function is actually representing the rate per day.
Assuming your times are in cells A1:A3, you can adjust your function to something like:
1000 / Sum(A1:A3) / 24
which will give you the rate per hour (by my calculations, £21.58/hr).
As others have mentioned, you will need to set the cell to a currency format.
Excel should be performing the calculation correctly, but it is just showing as a time. Format the result cell as "number" instead.
You can use the HOUR and MINUTE functions to get the hour and minute portions of the time values, however as lc mentions, you do need to ensure that the formatting of the cell is set to Number, as it will default to a time.
Assuming you have your hh:mm:ss values running down the page (column A), in the next column put the formula
=(A1-INT(A1))*24
underneath this you can put your formula
= 1000 / SUM(A1:A3)
but don't forget to format it as Number.

Resources