Excel If Statement finding number of days between two dates - excel

As an example I have three columns Target completion, Actual completion and Entered date
Column A Target Completion 1/5/13/2013
Column B Actual Completion 1/25/2013
Column C Entered Date 1/2/2013
I need to add 30 days to Column A (Target Completion) and then compare that new date to Column B (Actual Completion) and finally show the result in days.
Like this;
Column A Target Completion 1/5/13/2013
Column B Actual Completion 1/25/2013
Column C Entered Date 1/2/2013
Result = -10 days (30 days are added to column A then minus column B)
Column A Target Completion 3/1/13/2013
Column B Actual Completion 5/1/2013
Column C Entered Date 1/2/2013
Result = 30 days (30 days are added to column A then minus column B)
I have been trying to get this if statement to work …but no luck!! Thank you in advance.
=if(E14="",DATEDIF(DATEVALUE("06/28/2013"),TODAY(),"d"),DATEDIF(E14,C14,"d"))

Try EDATE() function
=Edate(A1,1)-B1
Reference .. http://office.microsoft.com/en-001/excel-help/edate-function-HP010342465.aspx?CTT=5&origin=HP010342402

Excel stores dates as the number of days since Jan 1, 1900, so to get the number of days just subtract. So to add 30 days to column A then subtract column B, in row 1 that would be:
=A1 + 30 - B1
The if statement would seem to be trying to do something like
=IF(E14="",TODAY() - DATE(2013,6,13),C14-E14))

Related

How to assemble Offset function with Condition?

I Have date data in Column A and values data in Column B.
My aim goal is that for each date in column A :
look if one value (column B) during 1 year is less than 90% of the corresponding Value of the date.
This is my data:
Output example :
I start at the first date (31/12/1986) and see the 900.82 value.
I calcul 900.82 * 0.9 = 810.73
So i look if value in line 3 is inferior to 810.73,
If not
I look if value in line 4 is inferior to 810.73,
line 5, 6, 7 ,8..... during 1 year (that mean I stop this the 31/12/1987).
If it is
I stop and i look the next date (01/01/1987) and do the same.
I am agree to translate it in VBA code, but it could be better on Excel.
I first tried an algo to understand the problem :
-Look the first date in column A
-Look the corresponding value in Column B and save it as Value
-Offset to the next date in column A
-Look the corresponding value in Column B and save it as Range.to.compare
-If Range.to.compare < Value * 90% then write "ok" in Column C
-Else, Offset to the next date in column A...
-Untill 1 Year (Untill Year(Date in Column A)<Year(Date in Column A) +1
I try to translate it in Excel or VBA.
This this what I tried by Excel :
But it works only for 1 day instead of 1 year
I think this is what you're after. I broke the calculation into multiple columns to show the steps.
First I calculate the 90% value, in column C.
Column D is where most of the magic happens. In column D I find all rows that have a date < the current date + 1 year, and get the value (Col B) for each of those rows. I then take the minimum of all those values. Note this is an array formula so you need to press shift-ctrl-enter after you type it in.
Now that I have the minimum from the each range, I just need to compare that with the 90% value.

Count cell per month

I look for a code for the number of times a value is in a cell, on a monthly basis
So
1-1-19 KS
2-1-19
3-1-19 KS
.
.
1-2-19 KS
2-2-19
3-2-19
January 2
February 1
is this possible?
Assume that your dates are in column A, your KS is in column B.
In cell D1:D12 you have the first of each month entered and given a custom number format of mmmm so it just shows January, February, etc.
The formula =MATCH($D1,$A:$A,0) will give the row number that the month starts on.
For simplicity I'll call this Start_Row.
The formula =MATCH(EOMONTH($D1,0),$A:$A,0) will give the row number that the month ends on.
I'll call this End_Row.
The formula INDEX($B:$B,Start_Row):INDEX($B:$B,End_Row) will set a reference in column B to all rows between the first of the month and the end of the month.
I'll call this CountRange.
Now you just need to count what's in that reference using either:
=COUNTIF(CountRange,"KS") to count just KS
=COUNTA(CountRange) to count any non-blank cells.
So the full formula, without any helper columns, would be:
=COUNTIF(INDEX($B:$B,MATCH($D1,$A:$A,0)):INDEX($B:$B,MATCH(EOMONTH($D1,0),$A:$A,0)),"KS")
Keeping in mind that D1 contains 01/01/2019

excel extract 6 digits from number, format as date and match with index match?

I have the following 2 worksheets.
Data:
Column B Column C Column D COLUMN E Column F
329115121601 3291 5555 =Date (MID(B8,9,2),MID (B8,7,2),MID (B8,5,2)) 50 <---- Week Number from date
I am trying to extract 6 digits from my number value in Columb B '151216' and want to put this into column E. The 6 digits represent a date which is 15th December 2016.
I am using mid to try and get the number and then date to try and format this as 15/12/2016 - however it's not working. Instead I get 15/12/16.
On my other sheet, 'Home' i am trying to look up the number from column B on sheet 'Data' using an index match (array formula) where the values in column C, D and E or F match.
Home:
Column H Column I Column J Column K
3291 5555 15/12/2016 or Week 50 {=IFERROR(INDEX(Data!$B:$B,MATCH(1,(Home!$H10=Data!$C:$C)*(Home!$I10=Data!$D:$D)*(IF(Home!$J10<55,Home!$J10,WEEKNUM(Home!$J10))=Data!$F:$F),0)),"No Po Found")}
The user should be able to enter either week number or a specific date and get a result.
For some reason, this formula works if the user enters a week number, but not if they enter a specific date. I'm not sure if this is a format issue with the date on sheet 'data' or with the index match formula. Please can someone show me where I am going wrong? Thanks
Excel defaults to 1916 when I input your formula, try adding "20"& to the start of the year parameter:
=Date("20"&MID(B8,9,2),MID(B8,7,2),MID(B8,5,2))
I think you are doing it well. Just need to format the date.
Right click on the cell that contains the date ( 15/12/16 ) then click on cell formatting option and choose the format you prefer.

How to collect number of days from a month in excel

I have a column which will have some days from a month in dd-mm-yyyy format. What I need to get total number of days from each month mentioned in that column. The column might not contain all days from each month.
Example :
Column A :
2017-01-01
2017-01-02
2017-01-17
2017-01-27
2017-02-08
In above example, from 2017 Jan, I have 4 days and from Feb I have one day. I need this count for a IF statement to run in C column. ie, in C1 there will be an IF function which will check the month in A1 and count the total number of days for that specific month from A column. If that count is below a specific digit, I need to perform a formula otherwise a different one. This will repeat for all C cell
If this column contains all date from each month I can use Day function to get total days, but here how Can I collect it
This will work: =SUMPRODUCT(1*(MONTH($A1:$A5)=D1))
And an example of manipulating basing on the result:
=IF(SUMPRODUCT(1*(MONTH($A1:$A5)=D1))<3;"good";"bad")
Another one when row number represents a month (JAN in C1, FEB in C2...):
=IF(SUMPRODUCT(1*(MONTH($A1:$A5)=ROW()))<3;"good";"bad")
In your case:
=IF(SUMPRODUCT(1*(MONTH($A1:$A5)=ROW()))<10;function1();function2())
Array formula - use Ctrl+Shift+Enter:
=SUM((MONTH($A$1:$A$5)=MONTH(A1))*(YEAR($A$1:$A$5)=YEAR(A1)))

Excel - Return dates in a list that are within 1 year of another date

I'm trying to write a formula that would return a date (B) from a list if that date is within 1 year of another date (A). If there are no dates in the list that are within 1 year of date A, then date B will simply be date A plus 1 year (365.25 days).
For example: My list is [2/15/16, 12/26/17, 5/15/19]. If date A is 1/1/16, then I want Date B to equal 2/15/16. If Date A was 2/15/16, then Date B would be 2/15/17.
The closest I've gotten is:
=IF(MIN(L:L)-A<=365.25,MIN(L:L),A+365.25), but obviously this won't work beyond the minimum date. I need to check against the whole list of dates, not just the minimum date.
My end goal is to make a list like this (column A after the first date is just the previous B:
From (A) - To (B)
1/1/15 - 1/1/16
1/1/16 - 2/15/16
2/15/16 - 2/15/17
2/15/17 - 12/26/17
Thanks for any tips in advance!
If I understand correctly, this should work
=IFERROR(LOOKUP(2,1/((($A$2:$A$4-C2)<365.25)*(($A$2:$A$4-C2)>0)),$A$2:$A$4),EDATE(C2,12))
Column A has the list of dates, C2 has Date A. Running some more dates in column C, copying the formula down:

Resources