How to add 2 hours to a current time of excel - excel

I have
29/06/2019 13:25:00
I want it to be
29/06/2019 15:25:00
I have 1000 rows, to do this action, I am using Excel

Or you can simply do:
= A1+(2/24)
If you want to use this formula for all the 1000 rows directly (assuming again the input column is A) you can simply adjust it like that:
= A1:A1000 + (2/24)

You can apply this function to your cells. It will add 2 hours, 0 minutes and 0 seconds.
=A2+TIME(2,0,0)

Related

excel formula to convert a number between 0-5 as 5 and 5-10 as 10 etc

I want to write a logic in excel that if value in a call is between 0 and 5 then the cell takes value as 5, if it is between 5 and 10 then the value taken is 10 and so on. How can I do this?
Try the int formula
=(INT(C5/5)+1)*5

Sub sum the same item

I have 2 columns:
A B
apple_type1 25
apple_type1 15
apple_type1 5
pears_type1 10
pears_type1 3
apple_type2 5
apple_type2 15
It is posible to Subsum the column B (without deleting the rows, whithout filters, without Pivot table) like:
apple_type1 0
apple_type1 0
apple_type1 45
pears_type1 0
pears_type1 13
apple_type2 0
apple_type2 20
Thank you!
If column A is sorted, then you could also use =IF(A1=A2,0,SUMIF(A:A,A2,B:B)) copied down:
This would be faster than using COUNTIF within the same formula, referring to Error 1004's answer (COUNTIF and SUMIF all need to 'look' at the range, so having two of these in the same formula will consume twice as much resources, but it has the advantage that it doesn't require column A to be sorted).
If you need to refresh the data a lot of times (new information got added for example), then I would advise sorting then using the formula I proposed.
Modify the formula and try:
=IF(COUNTIF(A3:$A$9,A2)>0,0,SUMIF($A$2:$A$8,A2,$B$2:$B$8))
Results:

Excel formula for greater than but less than with several tiers

I have a few hundred rows of data, and each has a number between 1 and 200, and I'd like to put them in categories of 1-5 depending on where that number is.
The categories look like this:
Zones Min Max
1 0 35
2 35 60
3 60 85
4 85 110
5 110 200
I want to assign it a Zone if it is greater than the Min, but less than the Max.
I have 2 formulas I've been working with to solve it. One is a nested IF AND statement:
=IF(A1<=35,1,IF(AND(A1<=60,A1>35),2,IF(AND(A1<=85,A1>60),3,IF(AND(A1<=110,A1>85),4,IF(AND(A1<=200,A1>110),2,"TOO BIG")))))
The 2nd formula attempts to use a SUMPRODUCT function:
=INDEX($C$2:$C$6,SUMPRODUCT(--(A1<=$E$2:$E$6),-- (A1>$D2:$D$6),ROW($2:$6)))
Rather than have to continue to adjust the numeric values manually, I set them as absolutes, which is why this formula is slightly different. The E column is the Max value set, and the D is the Min value set.
Any help would be appreciated!
Use this:
=MATCH(A1,{0,35,60,85,110})
Another way is to use VLOOKUP and you just need to set the min number:
=VLOOKUP(D2,$A$2:$B$6,2,1)
The key is the 4th parameter needs to set to 1 which means TRUE. It will find the closest value and return the zone for you.
But noticed that you have overlaps like 35 or 60 etc. that you will need to adjust your value column.

Convert 'x hrs y min z sec' to seconds

a) So I have a huge folder of .csv data with a column about time duration where the cells are 'x min y sec' (e.g. 15 min 29 sec) or 'x hrs y min z sec' (e.g. 1 hrs 48 min 28 sec). The cells are formatted by text.
I want to batch change them to the number of seconds, but I have no idea where to start. I can't get the data in another format.
I thought about somehow using 'hrs', 'min' or 'sec' as delimiters, but I don't know how to move from there. I also thought about using ' ' as delimiters, but then the first column is filled with either hours or minutes depending on the time duration.
I also thought about using PostgreSQL's SELECT EXTRACT(EPOCH FROM INTERVAL '5 days 3 hours'), but I haven't been able to work out how to use this on a column from a table.
b) Is there a better way to change this time format 'Fri Mar 14 11:29:27 EST 2014' to epoch time? Right now I'm thinking of using macros in Excel to get rid of 'Fri' and 'EST', then put the columns back together, then use the to_timestamp function in PostgreSQL.
In Excel if you have data in only those 2 formats and starting from A2 you can use this formula in B2 copied down to get the number of seconds:
=IFERROR(LEFT(A2,FIND("hrs",A2)-1)*3600,0)+SUM(MID(0&A2,FIND({"min","sec"},0&A2)-3,2)*{60,1})
It finds the relevant text then gets the number in front for each and multiplies by the relevant number to get seconds
You can do:
SELECT EXTRACT(EPOCH FROM column_name::interval)
FROM my_table;
The interval can use the regular time units (like hour), abbreviations thereof (hr) and plurals (hours). I am not sure about a combination of plural and abbreviation (hrs) though. If that does not work, UPDATE the column and replace() the sub-string "hrs" to "hours".
If you want to save the number of seconds in your table, then you convert the above statement into an UPDATE statement:
UPDATE my_table SET seconds_column = extract(epoch FROM column_name::interval);
I would split with space as the delimiter, then examine the second column. If it contains the string "hrs", then your seconds answer is:
3600 * column 1 + 60 * column 3 + column 5
Otherwise it is:
60 * column 1 + column 3

Excel VBA to count records that have a certain number of elapsed seconds

I am trying to report "Number of Elapsed Seconds" in these breaks: Less than 15 minutes, 15 to 19 min, 20 to 24 min, 25 to 29 min, 30 to 45 min, 45 to 60 min, and 60 min or more.
I have a field that shows elapsed seconds and I am able to get the breaks I want -- In Total -- by using the following formula:
=SUMPRODUCT((ABS(TestTable!$AF$2:$AF$50)>=0)*(ABS(TestTable!$AF$2:$AF$)<=899))
(where 'TestTable' is the sheet where the data is located and Col AF is where elapsed seconds is stored). The problem?
I need to cut each break down by another field. Also in 'TestTable' is a field with either PRODx or PRODz in it (it's Col H).
So I need to say "If Col H = PRODx, then count how many records are less than 15 min and put it in a certain cell ---THEN--- if Col H = PRODz then count how many records are less than 15 min and put that result in a different cell".
Anybody know a way to write this?
if you have excel 2007 or later, COUNTIFS should work out for you.
=COUNIFS(H:H,AF:AF,"<900",H:H,"PRODx") for less than 15 mins, and PRODx
=COUNIFS(H:H,AF:AF,"<900",H:H,"PRODz") for less than 15 mins, and PRODz
then for the ranges you expand the selection
=COUNIFS(H:H,AF:AF,">=900",AF:AF,"<1200",H:H,"PRODx") for 15-19 mins, and PRODx
=COUNIFS(H:H,AF:AF,">=900",AF:AF,"<1200",H:H,"PRODz") for 15-19 mins, and PRODz
keep repeating this for all the ranges of time/PRODs that you need
In cell A1, type:
=COUNT(IF(H:H="PRODx",IF(AF:AF="Less Than 15 Seconds",M1:M5)))
M is just another random column
In cell A2, type the same, but change PRODx to PRODz.
Make sure to enter all formulas as an array formula, by hitting CTRL + SHIFT + ENTER after typing, instead of just enter.
See this link for more: Count If WIth Multiple Criteria
EDIT
If you must have a VBA solution, let me know. Otherwise, you don't need VBA. Also, if you are running Excel 2007 or above, you can use the CountIfs function, which will be cleaner and less resource intensive than the Array formula above.

Resources