In Excel, I am trying to compare a forecast date against a target date and state in the 3rd column the difference, I have searched for a formula to put in the 3rd column such as DATEDIF (F5, G5,"m") but this is not able to state the difference if the projected date is less than the target date,
Please see example below:
EXCHANGE Target Date EXCHANGE Forecast Date EXCHANGE Difference
01/12/2018 11/01/2019 1
01/08/2017 16/02/2019 18
02/08/2017 01/06/2017 #NUM!
Use some Error handling, if the date is in the past, flip the calculation and multiply it by -1 or subtract it from 0. It's annoying that the function doesn't handle this itself but oh well...
IFERROR(DATEDIF(F5,G5,"m"),DATEDIF(G5,F5,"m")*-1)
IFERROR(DATEDIF(F5,G5,"m"),0-DATEDIF(G5,F5,"m"))
EDIT:
To evaluate weeks you would use the same function but taking the difference in days, you can then divide the result by 7 (make use of the ROUND() function if you don't want a decimal answer)
IFERROR(DATEDIF(F5,G5,"D")/7,0-DATEDIF(G5,F5,"D")/7)
IFERROR(ROUND(DATEDIF(F5,G5,"D")/7,0),ROUND(0-DATEDIF(G5,F5,"D")/7,0))
Related
Assuming 421 stands for April 2021 and 1299 for December 1999, what would be the correct formula to convert the digits in to the corresponding date format in excel?
Adjust the 30 as you see fit:
=IFERROR(DATE(IF(VALUE(RIGHT(A1,2))<30,2000+RIGHT(A1,2),RIGHT(A1,2)),LEFT(A1,LEN(A1)-2),1),"")
Actually, here is a one-liner (note, to get the correct century the formula is posted lower in the answer and is more complicated):
=DATE(RIGHT(A1,2),LEFT(IF(LEN(A1)=3,0&A1,A1),2),1)
DATE requires 1) Year 2) Month and 3) Day
So, it's easy to get the year (just take the two most digits)
However, it's trickier to get the month, since it can be 3 or 4 digits, so you need some if logic to add a 0 in front if only 3 digits and THEN take the left two digits to extract the month.
Finally, you have to have a day for the formula, so just put a 1. Then format the cells as desired to whatever date format. See screenshot.
In order to get the correct century, then the formula gets complicated :) Basically, it says if the date is greater than now, subtract a century. If it is less than now, then go with that date.
=IF(DATE(YEAR(DATE(RIGHT(A1,2),LEFT(IF(LEN(A1)=3,0&A1,A1),2),1))+100,MONTH(DATE(RIGHT(A1,2),LEFT(IF(LEN(A1)=3,0&A1,A1),2),1)),DAY(DATE(RIGHT(A1,2),LEFT(IF(LEN(A1)=3,0&A1,A1),2),1)))>NOW(),DATE(RIGHT(A1,2),LEFT(IF(LEN(A1)=3,0&A1,A1),2),1),DATE(YEAR(DATE(RIGHT(A1,2),LEFT(IF(LEN(A1)=3,0&A1,A1),2),1))+100,MONTH(DATE(RIGHT(A1,2),LEFT(IF(LEN(A1)=3,0&A1,A1),2),1)),DAY(DATE(RIGHT(A1,2),LEFT(IF(LEN(A1)=3,0&A1,A1),2),1))))
I am looking for a formula where I can put a 5 digit Modified Julian Date and have it convert it to today's date for me.
I did it in a way where I have a separate sheet with a table but although it works, I am looking for a way without the need of a separate table. Here is some information:
00000 should translate to 11-17-1858
58890 should translate to 02-11-2020
Every time the number goes up 1, it should go up 1 day. This needs to have leap years in consideration as well. Any help will be appreciated.
Here is a website that currently does the conversions:
http://www.csgnetwork.com/julianmodifdateconv.html
This has to be done without macros, literally need it in formula format.
Just subtract 15018 and format the result as a date.
Why 15018 and not 15020?
In Excel, 1-Jan-1900 value is 1
In your date scheme 15020 = 1-Jan-1900
But, if you had the number 15020 to convert and subtracted 15020 it would --> 0, not the desired 1.
Therefore we reduce the 15020 by 1 to 15019.
Next, there is a deliberate "bug" in Excel, widely discussed both on SO and the internet, whereby the year 1900 is erroneously classified as a leap year.
So for any date equivalent that is after 28-Feb-1900, we have to subtract an extra 1.
If you might be dealing with dates between 1/1/1900 and 2/28/1900 you will need to modify the formula to take that into account.
This is a follow up to an earlier question.
#ForwardED I am trying to convert your original single static formula into a single dynamic formula.
Unfortunately my employer's filters will let me up certain things to a hyperlink, but will not let me download or view from the same site. I am also trying to come up with a formula for floating dates.
Below is a copy of the expanded explanation I gave on the original question. I am not sure if you missed it or not. It deals with holidays that have a set date like Christmas, 25th of December of every year. However if it fall on a Saturday the time of work is the Friday and if it is on a Sunday the day off is the Monday.
Dealing with a holiday falling on a Saturday or Sunday
Again we need to refer to some cell in your spreadsheet with the year so I will again use Q10 as the example and we will assume a date of 2014/10/24.
=IF(WEEKDAY(DATE(YEAR(Q10),12,25))=7,DATE(YEAR(Q10),12,24),IF(WEEKDAY(DATE(YEAR(Q10),12,25))=1,DATE(YEAR(Q10),12,26),DATE(YEAR(Q10),12,25)))
The formula checks first if the weekday is a Saturday. We do this using a function that will return the day of the week See step 2) from the original question. It is this part from the equation above:
WEEKDAY(DATE(YEAR(Q10),12,25))
It will return a single integer 1 through 7 corresponding to the day of the week the date function results in, in this case. If its a 1 we known its Sunday, if its 7 we know its Saturday. So the check for Saturday is:
WEEKDAY(DATE(YEAR(Q10),12,25))=7
If WEEKDAY()=7 is true then we provides the date of the day before which is really just subtracting 1 from the date we were looking at. We use this part of the formula to calculate that:
DATE(YEAR(Q10),12,24)
notice how I changed the day from 25 to 24. An alternate way would be to recycle our date and make the computer do one more calculation using this formula:
DATE(YEAR(Q10),12,25)-1
or
DATE(YEAR(Q10),12,25-1)
That all sits in the TRUE portion of the if statement. so if the date does not fall on Saturday then we wind up in the FLASE portion of the IF statement. Here we check with a second IF for the date falling on a Sunday. we use the same theory and process as we did for the Saturday check.
IF(WEEKDAY(DATE(YEAR(Q10),12,25))=1,DATE(YEAR(Q10),12,26),DATE(YEAR(Q10),12,25))
Placing an IF statement inside an IF statement is commonly referred to as "nesting". This whole IF statement happens in the FALSE portion of the previous IF that checked to see if it was Saturday. This time we checked for Sunday:
WEEKDAY(DATE(YEAR(Q10),12,25))=1
When this is true, then we need to increase the date by 1 day instead of decreasing it like was done for Saturday:
DATE(YEAR(Q10),12,26)
or
DATE(YEAR(Q10),12,25)+1
or
DATE(YEAR(Q10),12,25+1)
So that was the true portion of the Sunday check. Logically speaking the only way to get to the FALSE portion of this nested IF statement is to fail the Saturday check and then fail the Sunday check. Which means you do not need to go through and check if is the WEEKDAY comes out as 2, 3, 4, 5 or 6! Its one of those by the process of eliminating Sunday and Saturday (1 and 7). And if the date falls on Monday-Friday we dont need to change the date and can leave it just as is:
DATE(YEAR(Q10),12,25)
And I realized I did not explain how the date function works, though I think I tried to in one of the previous questions...regardless! DATE(arg1,arg2,arg3) requires three different arguments as integers or other functions that return integers.
arg1 is the year so 2014, 1995, 1965 are all acceptable integers. Also we could use YEAR(Q10), where the cell Q10 holds the date of 2014/10/24. In this case YEAR(Q10) would return 2014.
arg2 is the month and needs to be an integer in the range of 1 to 12. Again you can always use a formula that returns an integer in that range as well such as MONTH(Q10) which from our previous value of Q10 would return 10.
arg3 is day and similar to the above it needs to be an integer. A formula such as DAY(Q10) would return a value of 24.
What this means is if we know what day a holiday is on we can force it to a date by supplying a set month and day, and letting the year be determined by a formula that supplies the year you are interested in. So if you look at the last formula you can see we fixed the month at 12 and the day at 25. They year will be determine from the year of the date supplied in cell Q10.
I want to get the difference between two dates, but I want the result to be in decimal numbers, for example if the difference is (1 Year and 6 Months) I want the result to be (1.5) which means Year and a half!
There is a specific function which does this in excel - YEARFRAC function - it calculates slightly differently according to the 3rd argument, see excel help for more but this is the basic version
=YEARFRAC(A2,B2,1)
Where A2 is the start date and B2 the end date. This is accurate to the day, I assume that's what you want
To provide a valid input to the NPV and IRR functions, I'm trying to create a range of values of annual even returns for a given number of years. Although question is also valid for any similar excel function, my specific case is related with NPV and IRR.
My initial investment is 25000$ and I get 5000$ from that investment annually for 10 years. Interest rate is 10% for NPV and IRR.
Instead of providing these values like BEFORE I'm looking for a way similar to AFTER, if possible without any macros, only by using a few functions?
Your first formula is actually discounting a 25000 investment made in 1 years time, then receiving cashflow of $5000 a year from the end of year 2, year 3 .... year 11
You wanted
=NPV(C1,C5:C14)-C4
=5777.84
which as an annuity can be calculated directly with
=-PV(10%,10,5000)-25000
=5777.84
On your second formula
=RATE(10,5000,-25000)
=15.1%