Trying to Sum negative times - excel

I am trying to sum two cells that have hh:mm's in them. Some of these cells may start with a + that I have removed but other are negative.
The highlighted cell has this formula in it.
=SUM(IF(LEFT(R6148,1)="+",RIGHT(R6148,LEN(R6148)-1),R6148),IF(LEFT(R6149,1)="+",RIGHT(R6149,LEN(R6149)-1),R6149))
What I was expecting is that under home 1 will be -05:00 and so on for the other homes.
Thanks

If the Time is Text then you can convert this using below formula then sum it:
=LEFT(A1,SEARCH(":",A1)-1)-(MID(A1,SEARCH(":",A1)+1,2))/69

Excel can't handle negative times, so these cells are presumably either text cells or use a single quote in front of the operator. You need to convert them to numbers before doing the math.
I would suggest separating the operator (+ or -) from the string, converting the hours to a number, and then recombining the operator and the hours. Because you're converting a time in hours to a number, it will be returned as a fraction of a whole day (e.g., 1 hour = 1/24 = 0.0416667), so you would multiply tit by 24 to get back to hours.
=(NUMBERVALUE(LEFT(B2,1)&NUMBERVALUE(RIGHT(B2,LEN(B2)-1)))+NUMBERVALUE(LEFT(B3,1)&NUMBERVALUE(RIGHT(B3,LEN(B3)-1))))*24
A better solution may be to convert all values to decimal numbers instead of times. You'd have to enter minutes as a decimal (e.g., 1 hour and 15 minutes = 1.25 hours), which could be tough for folks to do on the fly without a calculator, so you could provide a helpful conversion table from minutes to decimal hours. Timekeeping is often limited to some minimum interval, so the conversion table could be pretty short (e.g., if it's a minimum 5 minute interval, you only have 11 possible values for 0 minutes through 55 minutes).

Related

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.

Excel: Comparing Times to get minutes apart

I'm trying to get the + and - between two times but if the time I am subtracting from is greater than the time I am subtracting it gives me the difference in 24 hours.
I would like it to show this:
Perhaps this needs to be done in VBA. Have column B be the time to compare to and put max time apart as 12 hours, either positive or negative. So if the time is different by over 12 hours it becomes a negative instead of positive or vise-versa?
#tysonwright that is the best way to do it. Thanks. I assumed there was a better process but apparently there is not. So with that, I change the date to the next day to get 23:59 to 0:01.
If your clockin is in A1 and your Schedule is in A2, your Difference should be:
=IF(A1>B1,TEXT((A1-B1),"-h:mm"),TEXT((B1-A1),"h:mm" ))

How can I extract the hour part from a duration value in Excel?

How can I convert duration in excel to text ? I am having 1037:00:00 in a cell, which is the sum of certain durations. I want to extract 1037 alone. Excel returns "hours" when I try to extract with MID or use TEXT function.
If it is really the sum of some durations you can get the amount of hours by multiplying the cell by 24. The internal representation of a date or time cell is the number of days since beginning of the year 1900, so you have to multiply it by 24 to get the number of hours. (The year 1900 is not interesting for you as you just want a time span.) The Hour function does not work here because you get the day hour which is 5 in this case.
Be sure to format your target cell as regular number.
lets assume your cell with 1037:00:00 is in cell L40. You can use the following formula to pull the hours.
=INT(L40)*24+HOURS(L40)
Note this will only pull full hours rounded down. It does not take into account minutes or seconds.
Alternatives:
=Rounddown(L40*24,0)
This alternative is what Fratyx explained in his answer.

Formula to get the worked hours from time A to time B where B is past midnight

I'm using Excel to write down my shifts and get a total of worked hours per day and per week.
I structured it this way:
Everything seemed to work fine until I finished to work at 12.30 am. The result with my formula was -17 hours instead of 7. How can I fix my formula so that it displays a correct amount? I'm using the following formula and I want the result to be displayed in number format, not time.
=IF(C11=0,0,IFERROR(((C11-B11)-D11)*24,0))
What formula can I use?
Excel treats days as 1 for every day past Dec 31, 1899. Today happens to be 42,217. Time is nothing more than a decimal portion of a day. Today at noon was 42,217.5 and tomorrow at 03:00 will be 42,218.125.
Excel also treats boolean (e.g. TRUE/FALSE) values as either 1 or 0 when used in a mathematical equation. e.g. 0.5 + TRUE = 1.5 while 0.5 + FALSE = 0.5.
Test to see if the minuend is less than the subtrahend and if it is, add 1 to it using the result of the test itself.
=(C11+(C11<B11)-B11)*24
      
Finally, it should be mentioned that while you can subtract a larger time from a smaller time to receive a negative decimal value, the negative value cannot be interpreted as time since Excel does not recognize negative time. If you were not multiplying by 24 to retrieve the hours as integers and simply subtracting B11 from C11 the cell would be filled with hashmarks (e.g. ############) to show the error. e.g. 08:00 - 10:00 = (as time) #######.

How to get the difference in minutes between two dates in Microsoft Excel?

I am doing some work in Excel and am running into a bit of a problem. The instruments I am working with save the date and the time of the measurements and I can read this data into Excel with the following format:
A B
1 Date: Time:
2 12/11/12 2:36:25
3 12/12/12 1:46:14
What I am looking to do is find the difference in the two date/time stamps in mins so that I can create a decay curve from the data. So In Excel, I am looking to Make this (if the number of mins in this example is wrong I just calculated it by hand quickly):
A B C
1 Date: Time: Time Elapsed (Minutes)
2 12/11/12 2:36:25 -
3 12/12/12 1:46:14 1436.82
I Have looked around for a bit and found several methods for the difference in time but they always assume that the dates are the same. I exaggerated the time between my measurements some but that roll over of days is what is causing me grief. Any suggestions or hints as to how to go about this would be great. Even If I could find the difference between the date and times in hrs or days in a decimal format, I could just multiple by a constant to get my answer. Please note, I do have experience with programming and Excel but please explain in details. I sometimes get lost in steps.
time and date are both stored as numerical, decimal values (floating point actually). Dates are the whole numbers and time is the decimal part (1/24 = 1 hour, 1/24*1/60 is one minute etc...)
Date-time difference is calculated as:
date2-date1
time2-time1
which will give you the answer in days, now multiply by 24 (hours in day) and then by 60 (minutes in hour) and you are there:
time elapsed = ((date2-date1) + (time2-time1)) * 24 * 60
or
C3 = ((A3-A2)+(B3-B2))*24*60
To add a bit more perspective, Excel stores date and times as serial numbers.
Here is a Reference material to read up.
I would suggest you to use the following:
Combine date to it's time and then do the difference. So it will not cause you any issues of next day or anything.
Please refer to the image with calculations. You may leave your total minutes cell as general or number format.
MS EXCEL Article: Calculate the difference between two times
Example as per this article
Neat way to do this is:
=MOD(end-start,1)*24
where start and end are formatted as "09:00" and "17:00"
Midnight shift
If start and end time are on the same day the MOD function does not affect anything. If the end time crosses midnight, and the end is earlier then start (say you start 23PM and finish 1AM, so result is 2 hours), the MOD function flips the sign of the difference.
Note that this formula calculates the difference between two times (actually two dates) as decimal value. If you want to see the result as time, display the result as time (ctrl+shift+2).
https://exceljet.net/formula/time-difference-in-hours-as-decimal-value
get n day between two dates, by using days360 function =days360(dateA,dateB)
find minute with this formula using timeA as reference =(timeB-$timeA+n*"24:00")*1440
voila you get minutes between two time and dates
I think =TEXT(<cellA> - <cellB>; "[h]:mm:ss") is a more concise answer. This way, you can have your column as a datetime.

Resources