How can I calculate the amount of hours in a duration that exceeds 24hours? - excel

I've got a value of [HH]:MM:SS that is 76:30:00. I'd like to convert this value to a decimal value of the 'number' of hours - in this case 76.5.
However HOURS() returns 4 instead of 76. Probably because (3*24 + 4)=76
I'm using Libre Office Calc - but I assume it would be the same solution with Excel.

Depending on your regional settings this works at least in excel...
American, with regional settings "hh:mm:ss" and delimiter ","
=TEXT(H15,"[h]:mm:ss")*24
European, with regional settings "tt:mm:ss" and delimiter ";"
=TEXT(H15;"[t]:mm:ss")*24

Excel stores dates/times as days and fractions of a day, usually since 1/1/1900.
So all you need to do is multiply your time value by 24, and format the result as General or as Number with 1 (or more) decimals.

Related

Extract the hour from the h" hour(s) and "m" minute(s)" in excel

I have the list of data that showing the Hours and the Minutes that I extract from the system. I need to be extract the hours.
As example below, column B first row, the Hours would be 64 and the minutes would be 46.
But when I used the formula =Hour , its turn up the different value since its actually decimal number.
Cannot use left() , it will give the actual decimal number.
Updated:
We tried the #harun24HR 's but cannot readable the value.
But if you noticed, if i copy and paste the value is different. thats why the search not applicable.
4th Update:
To Solar Mike, I have tried the formula given from the thread the i think the value not readable
It's a time value which Excel stores as calculated value based on 24 hours = 1.
To retrieve the hours only you can use:
=INT(A2*24)
To retrieve the minutes only you can use:
=(A1-(INT(A1*24)/24))*24*60
Your time value is already a number in time format so you just need it to change it to decimal system. Dates and time values are numbers. Even if you see it as 30/09/2019 or 12:00:00, actually, for Excel, both cases are numbers.
First date Excel can recognize properly is 01/01/1900 which integer numeric value is 1. Number 2 would be 02/01/1900 and so on. Actually, today is 44659.
Now, about your data, you posted this screenshoot:
So the value is numeric, not text/string. In Excel, what you see is not always what you have. Probably that column has been formatted using custom mask. My fake data is like this:
The numeric value is 02/01/1900 16:46:36 (or 02/01/1900 4:46:36 PM it depends on your regional settings) but I've applied a custom format like this:
[hh]" hours" mm " minutes"
So what I have is a number but what I see is a text!
We have to work with the number (to be honest, ist's easier to work with numbers), so to extract the total hours, minutes and seconds.
Formula in B1: =INT(A1*24) total hours
Formula in C1: =INT(A1*24*60-B1*60) total minutes
Formula in D1: =A1*24*60*60-B1*60*60-C1*60 total seconds
This should guide you on whatever are you trying to achieve.
From your current sample data you try-
For hour =LEFT(A2,SEARCH(" ",A2)-1)
For minutes =RIGHT(SUBSTITUTE(A2," minutes",""),2)

How to add month and day to a numbered year in excel?

I have a column of years, 2000, 1990 > 900 (0900) > 1876 etc.... However I needed to have it in a date format e.g. 01/01/2000, 01/01/900 (01/01/0900). I can't work out how to do this. I can only see formulas which add days and months which are already in the format I would like. I only need it as 01/01 to input to QGIS as a csv file.
Dates are represented in Excel by real numbers. The integer part (to the left of the decimal place) is the number of days since 12/30/1899. The fractional part (to the right of the decimal place) is the fraction of the day. .5 = noon, .75 = 6pm, etc. How these numbers appear in the worksheet depends on the number format of the cell. So if your cell value is 36526 (or 1/1/2000) and the number format is "mm/dd/yyyy" you will see '01/01/2000' in the cell. If the number format is "mm/dd", you will see '01/01' in the cell.
I don't understand what you mean by "I only need it as 01/01 to input to QGIS as a csv file" but if you show me some code, and explain how the results you're getting differ from the results you want, I can probably help get you there.

Excel formula text to minutes

I want to convert text to minutes.
text hours = 8.15 'means 8h 15m
convert to minutes formula
=LEFT(A2,2)*60+IF(ISNUMBER(SEARCH(".",A2))=TRUE, SUBSTITUTE(MID(A2,FIND(".",A2)+1,2),".",""), "0")`
I getting error when calculate "0.15"
Please help, Thanks!
Total minute
=INT(A1)*60+(A1-INT(A1))*100
If want to extract minutes only then use
=A1-INT(A1)
Not clear exactly what you want, or exactly what you are dealing with.
The below assumes that dot is your system decimal separator. If dot is not your system decimal separator, then replace the cell references in the formulas below with: SUBSTITUTE(A1,".","your_system_decimal_separator")
Assuming 8.15 means 8 hrs 15 minutes, you can convert it to Excel time value with:
=DOLLARDE(A1,60)/24
and format the result as time (eg hh:mm or [mm] or similar).
If what you really want to see is the minutes as an integer (not as a time), then use
=DOLLARDE(A1,60)*60
DOLLARDE(A1,60) converts 8.15 to 8 + 15/60 (decimal hours) (e.g. 8.25)
Dividing by 24 or multiplying by 60 converts it either to an Excel time value, or decimal minutes, respectively, as Excel stores time (and dates) as fractions of a day.
Note: If 8.15 is decimal hours and equal to 8:09, then you don't need the DOLLARDDE part of the formula at all
You don't specify if 8.15 means 8,15 hours in decimal (it would be equal to 8 hours and 9 minutes) or if it means 8 hours and 15 minutes, so I developed both.
I guess the problem is that your decimal separator is the comma, and you need to convert the value into numeric.
My formulas for first version:
B5: =VALUE(SUBSTITUTE(A5;".";","))*60
C5:=INT(VALUE(SUBSTITUTE(A5;".";",")))*60
D5:=B5-C5
My formulas for second version:
B11: =(VALUE(SUBSTITUTE(A11;".";","))-VALUE(VALUE(SUBSTITUTE(A11;".";","))))*100+INT(VALUE(SUBSTITUTE(A11;".";",")))*60
C11:=INT(VALUE(SUBSTITUTE(A11;".";",")))*60
D11:=B11-C11
With this formulas you convert the string into numeric value, and then you work in the decimal system.
You could use
=minute(substitute(a2;".";":"))/100
to get "0.15" from "8.15".
There seem to be two possible problems in your question: either Excel can't recognise your "8.15" as being a timevalue, or you don't know how to calculate the number of minutes from a timevalue.
In case it's the second one, there's an easy formula for this:
=Hour(A2)*60 + Minute(A2)
Meanwhile I keep digging for a while to recognise "8.15" as a timevalue.
If ever you have the possibility to replace the "." by a ":", this might solve your problem immediately.

Converting unix time into date-time via excel

Trying to convert 1504865618099.00 Unix time into a readable date time.
I tried this:
=(UNIX + ("1/1/1970"-"1/1/1900"+1)*86400) / 86400
But it's not working.
To convert the epoch(Unix-Time) to regular time like for the below timestamp
Ex: 1517577336206
First convert the value with the following function like below
=LEFT(A1,10) & "." & RIGHT(A1,3)
The output will be like below
Ex: 1517577336.206
Now Add the formula like below
=(((B1/60)/60)/24)+DATE(1970,1,1)
Now format the cell like below or required format(Custom format)
m/d/yyyy h:mm:ss.000
Now example time comes like
2/2/2018 13:15:36.206
The three zeros are for milliseconds
=A1/(24*60*60) + DATE(1970;1;1) should work with seconds.
=(A1/86400/1000)+25569 if your time is in milliseconds, so dividing by 1000 gives use the correct date
Don't forget to set the type to Date on your output cell. I tried it with this date: 1504865618099 which is equal to 8-09-17 10:13.
TLDR
=(A1/86400)+25569
...and the format of the cell should be date.
If it doesn't work for you
If you get a number you forgot to format the output cell as a date.
If you get ##### you probably don't have a real Unix time. Check your
timestamps in https://www.epochconverter.com/. Try to divide your input by 10, 100, 1000 or 10000**
You work with timestamps outside Excel's (very extended) limits.
You didn't replace A1 with the cell containing the timestamp ;-p
Explanation
Unix system represent a point in time as a number. Specifically the number of seconds* since a zero-time called the Unix epoch which is 1/1/1970 00:00 UTC/GMT. This number of seconds is called "Unix timestamp" or "Unix time" or "POSIX time" or just "timestamp" and sometimes (confusingly) "Unix epoch".
In the case of Excel they chose a different zero-time and step (because who wouldn't like variety in technical details?). So Excel counts days since 24 hours before 1/1/1900 UTC/GMT. So 25569 corresponds to 1/1/1970 00:00 UTC/GMT and 25570 to 2/1/1970 00:00.
Now if you also note that we have 86400 seconds per day (24 hours x60 minutes x60 seconds) and you will understand what this formula does: A1/86400 converts seconds to days and +25569 adjusts for the offset between what is zero-time for Unix and what is zero-time for Excel.
By the way DATE(1970,1,1) will helpfully return 25569 for you in case you forget all this so a more "self-documenting" way to write our formula is:
=A1/(24*60*60) + DATE(1970,1,1)
P.S.: All these were already present in other answers and comments just not laid out as I like them and I don't feel it's OK to edit the hell out of another answer.
*: that's almost correct because you should not count leap seconds
**: E.g. in the case of this question the number was milliseconds since the the Unix epoch.
If you have ########, it can help you:
=((A1/1000+1*3600)/86400+25569)
+1*3600 is GTM+1
in case the above does not work for you. for me this did not for some reasons;
the UNIX numbers i am working on are from the Mozilla place.sqlite dates.
to make it work : i splitted the UNIX cells into two cells : one of the first 10 numbers (the date) and the other 4 numbers left (the seconds i believe)
Then i used this formula, =(A1/86400)+25569 where A1 contains the cell with the first 10 number; and it worked
You are seeing the date as ######## most likely because by definition the EPOCH times is in seconds - https://en.wikipedia.org/wiki/Unix_time. This means the number should be 10 characters long. Your number has 13 characters (see 1504865618099) and it is most likely in milliseconds (MS). In order to fix the formula just divide the number by 1000. Just keep in mind this way you'll loose the MS precision, but in most cases this is OK. So the final formula should be:
=A1/(86400 * 1000) + DATE(1970,1,1)
Just point and shoot.
Replace the C2 with your cell no. No need to format your Excel cell.
Also, you can use this unixtimestamp website to verify your data.
International format (ISO 8601):
=TEXT(C2/(1000*60*60*24)+25569,"YYYY-MM-DD HH:MM:SS")
2022-10-20 00:04:22
2022-10-20 00:05:20
2022-10-20 00:14:58
US format:
=TEXT(C2/(1000*60*60*24)+25569,"MM/DD/YYYY HH:MM:SS")
10/20/2022 00:04:22
10/20/2022 00:05:20
10/20/2022 00:14:58
Europe format:
=TEXT(C2/(1000*60*60*24)+25569,"DD.MM.YYYY HH:MM:SS")
20.10.2022 00:04:22
20.10.2022 00:05:20
20.10.2022 00:14:58
If you only need the date, remove the 'HH:MM:SS'.
=TEXT(C2/(1000*60*60*24)+25569,"YYYY-MM-DD")

Date is not converted exactly when read from excel

I have an Excel spreadsheet that is being read.
The value in the spreadsheet is 7/24/2014 10:43:33 AM
The cell value after being read using OpenXML is 41844.446908680555.
When I do this calculation to convert to a date:
dte = DateTime.FromOADate(double.Parse(value));
I get 7/24/2014 10:43:32 AM
Is this typical when converting date/time or am I missing something?
Thanks
It seems that DateTime.FromOADate(double.Parse(value)); is truncating rather than rounding the fractional seconds. Excel stores date/time as days and fractions of days since 1 Jan 1900 (with the intentional error of calling 1900 a leap year, supposedly for compatibility with Lotus 123 at the time).
Therefore, the number 41844.446908680555 translates to, given Excel's level of precision
7/24/2014 10:43:32.910
(actually: 7/24/2014 10:43:32.9099949030205)
Just format the cells as Dates. 41844.446908680555 is Excel's way of serializing the date value.
When Excel stores a date or time in stores it in a number format with the date January 1, 1900 = 1
so really when you’re storing a date with the date format you’re really just storing the numeric value of difference between the date and January 1, 1900
So for example 365 = jan-30-1900
And fractions of a number equal parts of the day so .5 = half a day or 12 hours.
And for the fun of it right now = 41885.75 or sept-3-2014 at 6PM or 41885.75 from jan 1 1900.
The reason why this is done is to now allowed dates to be used in mathematical functions. And it deals with a lot of problems that pop-up with dates such as leap year and also provides for easier ways to deal with time zones as well.

Resources