Calculate time differences - excel

I want to calculate time difference of a column in Excel, column data shown below:
08:06am-12:00pm
10:40am-11:30am
01:15pm-04:00pm
Please share any formula, reference or method to calculate time difference in Excel column.

This will do it:
=VALUE(MID(A1,9,5)&" "&MID(A1,14,2))-VALUE(MID(A1,1,5)&" "&MID(A1,6,2))
Apply a number format to the cell of hh:mm.

Please try:
=TEXT(LEFT(RIGHT(A2,7),5),"hh:mm")+IF(MID(A2,14,1)="p",1/2,0)-TEXT(LEFT(A2,5),"[hh]:mm")+IF(MID(A2,6,1)="p",1/2,0)-IF(RIGHT(A2,7)="12:00pm",-0.5)

It's pretty simple, actually:
=TIME(HOUR(B2),MINUTE(B2),SECOND(B2))-TIME(HOUR(C2),MINUTE(C2),SECOND(C2))
Where B2 and C2 both have times in them.
What it looks like there is that your column has BOTH times in it. You will have to split those columns first. Because the way you have it, the field will be interpreted as TEXT and nothing else.

Related

Excel - lookup between two dates and return a pre determined value

I have the following time frames which has a "Y" or "N" beneath them.
I then have a list of dates, by day, vertically as per below. Next to each date I would like to put a "Y" or "N" in the adjacent column based on whether that date falls between the dates mentioned above. In the example below the answer is typed manually but would like a formula to calculate this.
Any help on this is greatly appreciated, many thanks, Alan.
Firstly you should change your format to the picture I added below. By doing this, you can apply the formula I wrote to B5 cell. Then you can use flash fill property to find the predetermined values of every single date below.
If you face any problem, we can contact again. Have a nice day.

SUMIFS Excel Multi Criteria

I'm trying to do use SUMIFS to calculate the total QTY changes for drawings with a material ID that Matches the Pipe Indent Numbers and ignore the ones that are NOT listed the piping indent numbers column. Below is what I have so far but I know the "=D:D" looks wrong.
I don't know how to reference all the numbers in the Pipe Indent Numbers List(D:) as each their own criteria, so that if the Material ID matches ANY of the Pipe Ident Numbers it will sum it.
I need help with this because my actual Pipe Ident Numbers column have about 100 other numbers not just the 5 shown.
Also not sure would I need to have the drawing number in the formula somewhere too? Maybe that's what I'm missing...
=SUMIFS(C:C,B:B,"=D:D")
Any help would be amazing! Thanks :)
you can use
if you want to compare row by row
=SUMPRODUCT(c2:c6*(b2:b6=d2:d6))
if you want to compare the value in column b with all values in column d (of you do not use Excel 365 press CTRL+SHIFT+ENTER to enter the formular)
=SUMPRODUCT(c2:c6*(b2:b6=TRANSPOSE(d2:d6)))
Best Regards
Chris
Use:
=SUMPRODUCT(SUMIFS(C:C,B:B,D2:D6))
One can use D:D but that would do many unneeded calculations. One should limit the range to the dataset.

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!

Excel - issue with VLOOKUP formula - it doesn't pick dates

I need help with the below formula. I already tried to find a solution for this problem but no success.
If account number exists in column A in the 'Returns' tab and also in column A in the 'July Sales' tab, then I need to get date from the column B in 'Returns' tab.
I manually checked a few accounts on both spreadsheet and find some duplicates.
My formula is as follows:
=VLOOKUP(Returns!A:B,A:B,2,0)
Screenshots:
I tried to change format to text/general, text to columns and trim function but it's still not working.
Also, as I have over 200k rows in each table, can I use any different formula instead to speed this up?
Finally, is there any way to pick dates only if these are within 30 days
Thanks in advance.
You're using Returns!A:B as your lookup value, which doesn't make sense. Instead, try the following:
=VLOOKUP([#Account], tblReturns[[Account]:[Submit_Date]],2,FALSE)
where tblReturns is the name of the table on your Returns worksheet.
I've made the assumption that you're working with tables, since the data in your screenshots is formatted like the default table. If they're just normal ranges, the equivalent is
=VLOOKUP($A2,Returns!$A:$B,2,FALSE)
=IF(COUNTIF(RETURNS!A:A,A2)>0,B2,"NO RETURN INFO")
Not sure what you want done when the account is not found on the RETURNS worksheet. Change "NO RETURN INFO" to what ever text you want including "" for a blank. Make sure you apply the same format for cells in column F as you do in column B. Copy the above formula down as required.
try the below, which will return blanks for non-matches as opposed to errors;
=IFERROR(VLOOKUP($A2,Returns!$A:$B,2,FALSE),"")
I highly recommend an INDEX/MATCH combination over a VLOOKUP. It is MUCH faster, particularly if you are working with a large number of rows. It may even be faster than the COUNTIF solution suggested by #ForwardEd.
=IFERROR(INDEX(Returns!$B:$B,MATCH($A2,Returns!$A:$A,0)),"")

SUMPRODUCT several ifs

I´ve spent a lot of time with a formula in Excel and I´m still blocked. I hope you can help me.
I have a table in Excel with several values as shown in this
screenshot.
What I´m trying to extract is the number of Fruits sold in a specific month. That is, how many lemons were sold in January 2016, for example. This is the formula I´m using:
=SUMPRODUCT((B3:B38=E4)*(MONTH($A$3:$A$150)=12)*(YEAR($A$3:$A$150)=2015);$C$3:$C$150)
But the result is #N/A as seen in the screenshot.
What Am I doing wrong? Any help, please?
Thanks a lot in advance!
You can use arrays in excel to get this answer
{SUM(IF(MONTH(F$3&"1")=MONTH($A$3:$A$150),IF($E4=$B$3:$B$150,$C$3:$C$150,0),0))}
You can use this Sumproduct formula which uses array logic:
SUMPRODUCT((MONTH($A$3:$A$38)=MONTH(TEXT(G$2,"MMM")&1))*($C$3:$C$38=$F4)*
($D$3:$D$38))
Sumproduct Demo
Part of your problem is your ranges are not equal in length. B3:B38 has to be the same number of rows as $A$3:$A$150 and C3:C150. When rows are not equal things blow up on you.
=SUMPRODUCT(($B$3:$B$150=$E4)*(MONTH($A$3:$A$150)=12)*(YEAR($A$3:$A$150)=2015);$C$3:$C$150)
if you change your header row to be actual excel date format, and then change the cell display format to just show the month (as suggested by csanjose), then you can adjust your sumproduct formula as follows and copy to all cells in your table.
=SUMPRODUCT(($B$3:$B$38=$E4)*(MONTH($A$3:$A$150)=Month(F$3))*(YEAR($A$3:$A$150)=Year(F$3));$C$3:$C$150)
Fill your month-row with the last day of each month, then apply date format to show only month name.
The formula you should use is, for example, in g8:
=SUMIFS($C:$C;$B:$B;$E8;$A:$A;"<="&G$3;$A:$A;">"&F$3)
First column "F" doesn't have a column on the left to compare, so you can put a date in E3 or change a bit the formula (example of F8):
=SUMIFS($C:$C;$B:$B;$E8;$A:$A;"<="&F$3;$A:$A;">2015/12/31")
Take a look at the result
If you don't want to use a pivot table, you can use this formula to get what you need:
=SUMPRODUCT(($B$3:$B$150=$E3)*(MONTH($A$3:$A$150)=1)*(YEAR($A$3:$A$150)=2015)*$C$3:$C$150)
Then drag-fill the cell to copy it to every month column (just make sure you change the month number in the formula (and year if you're doing that too)), and then drag-fill down the columns.
That should work pretty food good :)
Good Luck!

Resources