Calculating time difference between [h]:mm - excel

I've got 2 fields in Excel that are formatted as [h]:mm and I need to find the value difference between them.
For example in G2 I have 4217:11 and in I2 I have 1703:11.
I know that the answer should be 2514:00 as it is 4217 hours 11 minutes minutes 1703 hours 11 minutes, however I can't figure out how to do this in Excel.
I've tried the simple minus formula, however I get a #VALUE error.
Any suggestions?

I just tried =G2-I2 and it worked fine for me ... if you're getting #VALUE error, then the data definitely isn't formatted like you think. Likely it's being formatted as text, and it just "looks" like it's in a time format.

One way to do it is to create a formula that rebuilds the value to what you want.
But it requires helper columns.
In J2 (or whichever is free)
=LEFT(G2;FIND(":";G2)-1)&":"&MID(G2;FIND(":";G2)+1;2)
In K2 (or whichever is free)
=LEFT(I2;FIND(":";I2)-1)&":"&MID(I2;FIND(":";I2)+1;2)
The above formulas will make text to the type of string you want.
Then in the next free column set the formating to [t]:mm as you said before and just do a =J2-K2
Sorry for the swedish but the formulas are above

Related

LEN function in Excel not returning a numerical value

I'm having a strange issue here with Excel. I'm working with a custom datetime format in one column...
9/1/2017 12:02:01 AM
This is cell C2. However, using LEN on this cell gives me this...
1900-01-15 00:00:00
I've tried changing the format to General, or Text, and messing around with some custom datetimes, but it doesn't help. I will get the same answer. My goal here is to use this as an exercise and trim the date and time, putting them in separate columns. This spreadsheet was originally created using Google Sheets, not sure if that might explain it?
UPDATE: Ok, so about 1 minute after posting this I think I figured it out? I used LEN in the column to the left of column C, so B. I had been using column D. For some reason, column B returned the numerical value. Obviously I'm very new to Excel. I didn't think column placement mattered in this case. Why does it?
That's because you have formatted the result to be shown as a date.
Remember, dates are simply really large numbers. So, what has happened here is that you get the correct result from LEN(), but then you have formatted this result to be interpreted as a date.
The date seems to indicate the result was 15. In dates, this is 15 full days from 1900 January 1st.
So, you just have to change the format of that cell from a date, to be a number :)

Time/hour calculation in excel

I’m so rusty on excel and I’m trying to work out a formula for this problem:
Shifts greater than 5 hours duration must take a 1 hour unpaid break.
I’m using for G5 =IF(G4>5:00:00,”1:00:00”,”0:00:00”)
G4 =shift duration, cell is formatted as [h]:mm
Once I get this to work I then add G4 and G5 and to get the shift finish time.
It sounds so simple but it’s driving me crazy!!! Any help would be appreciated!
Excel stores time field internally as numbers, where 1 is a complete day (which is 24 hours).
If G4 has the value "06:30" (a time ), Then a formula in G5 like this:
=G4*24, will give you the numeric value 6.5.
You formula to check for more than 5 hours can be:
IF(G4*24>5,"01:00:00","00:00:00")
But this will return a text (i.e.:"01:00:00"). This can be solved by adding the function TIMEVALUE()
=TIMEVALUE(IF(G4*24>5,"01:00:00","00:00:00"))
EDIT:
Another way can be:
=IF(G4>TIME(5,0,0),"01:00:00","00:00:00")

Date_time format does not recognise AM/PM

I have the following time series dataset from ebuttons.
When I extracted something wrong happened and in most of the data of each buttom I get some times formatted as follows
I have tried several things
1)= text(cell number , "hh:mm:00) in excel
2)I have also tried to separate date and time in excel by holding date constant
3)In rstudio I have used different function as as.POSIXct(concrete$time_date, format = "%m-%d-%Y %H:%M:%S") and as.Date
But there is something really wrong as I get this when trying option 1 and 2 in excel:
I think the time AM/PM whatever I tried is recognized as a text. But I do not know what else to try after having change format in different ways.
I am working on MAC
I really appreciate our attention in advance,
Best
Mara
Considering A1 as the first cell with data, try this one:
Select column B and give format as short date in the way you need.
Select column C and give format as Hour in the way you need.
On A2 place formula =MID(A1,1,8) (Maybe instead of 8 is 9, but check your data)
On A3 place formula =TIMEVALUE(MID(A1,9,20))
Drag the formulas down.
Hope it helps!

Trouble with looking up min value between different conditions

I am trying to find the minimum time for a fixed date between two different times.
Been trying out different variations but nothing works.
This is on excel 2016, I tried out yesterday with a similar code on a different spreadsheet (a test sheet I created) and it worked. Unfortunately it was on another laptop that I have no longer access to.
Tried out the same code on the sheet I am to use and it did not work.
{=MIN(IF((Date<=D5)*(Date>=D4);Time;"");IF((Time<=D7)*(Time>=D6);Time<""))}
{=MIN(IF(;IF((Time<=D7)*(Time>=D6);Time<""))}
D5 is the actual date I want to look at (line 1), since it did not work for my I tried out putting an earlier date in D4 but same result (line 2).
D7 and D6 is the end and start time I want to find the value between.
Tried naming the ranges so Date range refers to the dates (E2:E55220) and Time is the time range I want to find the minimum value in (C2:C55220).
Value I end up with on all attempts is 0
Alternative formula to the array. It should do the same thing:
=AGGREGATE(15,6,myTIME/((myDATE<=F4)*(myDATE>=F3)*(myTIME<=F6)*(myTIME>=F5)),1)
Now this formula works with the assumption that your dates are actual excel dates and not text looking like a date. Same goes for for time. You can test it with the following formula:
ISNUMBER(E2)
or
ISTEXT(E2)
Where E2 is a cell containing a date or a time. Excel stores dates as integers and times as decimals. IF your information is stored as text, it is probably easier to convert them first then trying to apply your formula con the converted results. you can convert withing your formula but it will tend to make the formula really ugly and long.

Getting minutes between different dates in excel

I'm trying to calculate the time between the dates , at the beginning the formula
was working fine but I've noticed that it does not work when the date is different
For example , I have the following information on cell A1: 09/15/2016 10:00 AM
On Cell B2 I have: 09/16/2016 10:00 AM
The formula is just B2-A1 but instead of giving me a result of 24 hours is just giving me 0 . I believe the formula is not recognizing that these are 2 different days and is just doing 10-10
Any idea how to fix this ?
I was able to get the result 24 by setting a custom format of [h] (you will have to type it into the 'Type:' box) on cell C1 while using the formula =B1-A1
Excel Reference
'Format Cells' view
The problem with just using =B1-A1 is that if either or both of those cells is not populated then you will get weird numbers in C1. You may want to make C1 display as a blank cell unless both boxes are populated, try something like this =IF(OR(ISBLANK(A1),ISBLANK(B1)),"",B1-A1)
The reason for the weird numbers is that Excel calculates time based on a predefined decimal system that indexes time starting at like 1/1/1900 or something like that. So when manipulating or calculating time, that is something that you always have to keep in the back of your mind.
Hope this helps.
Formation the destination cell to will do but since you have date and time combined it will show as 1 calendar day difference 0 only means that 12 am after the 1 day difference, I know it does not make any sense but its Excel...
If I was you, on column A, I would add the date, and on Column B, the time.
then just work with the time, as both combined can be tricky
Don't forget to format your cells!! (right click>Format Cells>Time>3/14/12 1:30 PM)

Resources