Index Match to match date between two dates - excel

I have a date column B that are dates. My Fiscal year begins April 1 and ends March 31, I have my date ranges below:
Here is my formula including named ranges. I'm getting N/A error, and I'm not sure what I'm doing wrong.
{=INDEX(fiscalyear,MATCH(1,(startdate>=B2)*(enddate<=B2),0))}

You can get rid of the lookup with:
="FY" & YEAR(EOMONTH(B2,9))

Since any fiscal year starts right after a fiscal year ends you can just use:
=INDEX(fiscalyear,MATCH(B2,startdate,1))

Although both of the previous answers are correct and the formulas are simpler than the original one, I would like to point out where the original problem was - the comparison operators were swapped there.
It was:
{=INDEX(fiscalyear,MATCH(1,(startdate>=B2)*(enddate<=B2),0))}
Must be:
{=INDEX(fiscalyear,MATCH(1,(startdate<=B2)*(enddate>=B2),0))}

Related

Excel round multiple dates to a single one

I'm trying to put multiple rows which contain a date of the month between the first and last day of the month and I want to put them togeather as the first of the month dpeending on which month they are in:
for example; if they have the month of 12 i want to make them the 01/12/2020 if it was november 01/11/2020 and so on...
What i am looking for is to get three or more dates into a single one:
Date
03/12/2020
16/12/2020
27/12/2020
And make it:
Date
01/12/2020
Thanks for any help on how i could go about this, im struggling to find a solution
(I have tried text join and concatenate and neither work)
If you have Excel365 then use-
=DATE(2020,UNIQUE(MONTH(A1:A4)),1)
If you have dates with different years then try below formula.
=DATEVALUE("01-"&UNIQUE(TEXT(A1:A4,"mm-yyyy")))
Pretty unconventional way of doing it but works:
=EOMONTH(EDATE(AVERAGE(A1:A12),-1),0)+1
Where A1:A12 is a range of dates.
You have not specified well whether your dates are strings or actual Excel dates. Nor is it clear to me whether this is an example of a single cell in a larger row. The solution would be different based on the answer to these questions (which I do not have enough reputation to put as comments).
If you already have these values as dates put a new value in an adjacent column. Assuming the existing date value is in cell A1:
=DATE(YEAR(A1), MONTH(A1), 1)
However, if the date value is actually a string you will need to hard code the extraction of the values. Assuming, the are in fixed length strings as your image shows, with dd/mm/yyyy format:
=DATE(RIGHT(A1, 4), MID(A1, 4, 2), 1)

WORKDAY() returns unexpected value on blank cells

I am trying to set up conditional formatting to highlight when a date is in the weekend with this formula:
=WEEKDAY(A1,2)>5
This works fine when applied to a range only containing dates. However when there is any blanks or numeric values these also get formatted. I've tested and the formula =WEEKDAY(A1) where A1 is blank returns 6, implying it is a Saturday.
Question 1:
Does anyone know why this is?
Question 2:
How do I get around this, and leave blank cells unformatted? I've considered ISNUMBER and ISBLANK which would work for blanks, but not for numeric values within the range.
To detect the cell formatted as Date for limited number of date styles you can use CELL function:
=CELL("format",A1)
e.g. for date format m/d/yyyy it will return "D4" which can be used for testing the value being entered.
Please refer the answer provided by Foxfire and Burns and Burns for the other query.
A blank value equals to 0.
Dates in Excel work as numbers. First day Excel can recognize is number 1, which equals to 1st January 1900 (Sunday), number 2 means 2nd January 1900, and so on. Actually today is 25th september 2019, which numeric value is 43733.
So because 1 it's Sunday, 0 it's Saturday (it would be 0 JAnuary 1900, but that's not posible)
That explains the Does anyone know why this is?
About second question, because dates are also numeric values, you'll need to figure out how to check them. Maybe if the dates are in a specific range, you can check first if that number is between those values.
To see the numeric value of a date, just type any date in a cell, and change format to General or Numeric

Counting Number of Months between Two Dates in Excel

So I am attempting to simply count the number of months bewtween an earlier date and today, which will be in the B:B column; once the number of months have been counted, the result is then multiplied by 28, then added back to the original date. Note the requirement: Result >= Today, so basically if the result is less than today it needs to add another 28 days. The current formula I made only works if the dates are in the current year (and I am not 100% sure if this formula works, it appears to so far though.)
Here is my defunct formula, but maybe someone can get a general idea from my above comments and the below formula of what I am attempting to achieve here:
=IF(B89="","",IF(I89="X","LEG",IFERROR(IF((MONTH(TODAY()-B89)*28)+B89<TODAY(),(MONTH(TODAY()-B89)*28)+B89+28,(MONTH(TODAY()-B89)*28)+B89),"Future")))
Thank you in advance for your assistance!
Note: I just want to point out that the reference to I89 is insignificant in the above. I just didn't want to remove it in case I deleted the wrong parenthesis or some other typo, so I decided to leave in there. So basically you would not need to necessarily worry about the first two "IF" statements, nor the IFERROR, unless you just wanted to!
2ND EDIT: Okay I decided to strip down formula, original post's formula is above, the stripped version below:
IF((MONTH(TODAY()-B89)*28)+B89<TODAY(),(MONTH(TODAY()-B89)*28)+B89+28,(MONTH(TODAY()-B89)*28)+B89)
You should not use MONTH() for this purpose as this will lead to wrong results in some cases, and certainly when the B89 date is in another year.
Instead see how many days you are past the last multiple of 28 days since B89, and go back to that date (by subtracting), and then add another 28 to it:
=TODAY() + 28 - MOD((TODAY()-B89), 28)
The earliest date this can give is the date of tomorrow. If today should be an acceptable outcome of the formula, then replace TODAY() with TODAY()-1, which results in this formula:
=TODAY() + 27 - MOD((TODAY()-1-B89), 28)
How about something like this:
=IF(B89="","",IF(I89="X","LEG",IF(IF(B89<=TODAY(),B89+28*IF(AND(B89<TODAY(),TEXT(B89,"mmyy")=TEXT(TODAY(),"mmyy")),"1",(TEXT(TODAY(),"yy")*12+MONTH(TODAY()))-(TEXT(B89,"yy")*12+MONTH(B89))),"Future")<TODAY(),TODAY(),IF(B89<=TODAY(),B89+28*IF(AND(B89<TODAY(),TEXT(B89,"mmyy")=TEXT(TODAY(),"mmyy")),"1",(TEXT(TODAY(),"yy")*12+MONTH(TODAY()))-(TEXT(B89,"yy")*12+MONTH(B89)))))))
Got a little long now, but you have a lot of criteria :)

Excel month formula

I want to show specific text for whether something is due for any given month in a financial year or overdue if that month has passed. The formula I am using is as below and works fine until I get to January.
I am using the numerals 7-12 in this formula to represent respective month but am unsure how to ensure the number 1 relates to the next year. For that matter I guess my equation below for overdue for December won't work either.
=IF(MONTH(TODAY())=12,"DUE",IF(MONTH(TODAY())<=12,"",IF(MONTH(TODAY())>=12,"Overdue")))
Any help would be appreciated
Instead of the month number, let A1 equal the first of the month in which it's due. (Note the first of the month is what you'll get if you just type in the month and year, eg August 2014)
=IF(TODAY()<A1,"",IF(TODAY()>EOMONTH(A1,0),"Overdue","Due"))
Here is a solution that you can use. This includes a =YEAR( function and an =AND function to extend on what you already have.
The formula you can use is here.
=IF(AND(MONTH(TODAY())=MONTH(A2),YEAR(TODAY())=YEAR(A2)),"Due",IF(AND(MONTH(TODAY())>MONTH(A2),YEAR(TODAY())>=YEAR(A2)),"Overdue",""))
you can add the year into the comparison which will eliminate your problems with January.
Just wrap the month check and year check in an =AND( function when both conditions are TRUE you can enter your result.

Compare if year in date is prior to today's year

I have a date in the format of "4/26/2013". I want to see if that date is prior than the current year, whatever that current year may be (don't want to hardcode 2013) and count how many of the rows match that criteria. Say there are 6 rows of dates in that format:
=COUNTIF(C2:C7, YEAR(Today()))
This threw an error. I'm new to Excel, so I probably made a huge mistake! Can anyone see what is wrong with this?
Thanks!
If C2:C7 contain dates you need to compare them to the 1st of January in the current year, e.g.
=COUNTIF(C2:C7,"<"&DATE(YEAR(TODAY()),1,1))
or you can use SUMPRODUCT like this
=SUMPRODUCT((YEAR(C2:C7)<YEAR(TODAY()))*(C2:C7<>""))
I just figured it out. My syntax was wrong. The answer to the above example was:
=COUNTIF(C2:C7, ">"&YEAR(TODAY()))
That returned the number of dates in C2 - C7 that were prior to the current year.

Resources