Excel Subtract months from specified date? - excel

How will i subtract months from specified date using datediff function?
for example:
17/10/2013 -(3 months) = 17/07/2013?

If your input is in A1, this will give you the date 3 months earlier:
=DATE(YEAR(A1),MONTH(A1)-3,DAY(A1))
Date creates a date given the year, month, and day provided. It will handle negatives correctly (so it will work in February, adjusting the year as needed.)
Datedif returns the difference between two given dates -- the reverse of what you're looking for.
Datediff is a function in MS SQL and Access.

Related

Finding out the difference between two quarter periods in Excel

Need to find out the difference between two quarter periods.
Data as shown below:
Any plan sold year on same quarter (Let's say Oct, Nov or Dec) and the Check Month quarter ( Let's say May, June, July) would have the same difference in the quarter periods.
Need the formula to catch the difference between two quarter periods.
Eg:
Plan Sold Year: 2013 Dec
Check Year: 2018 Feb
Difference in periods: 18 periods (including 2013 quarter period as well)
One way of tackling your question is to work out the Plan Sale Quarter Start Date and Check Quarter End Date, then do a calculation between the two dates to work out the periods (full quarters) in between.
In my solution I used two helper columns being PSQStart and CQEnd that represent the two critical dates mentioned above.
Formulas are:
PSQStart =DATE($A2,FLOOR(MONTH(DATEVALUE("1/"&$B2&"/"&$A2))-1,3)+1,1)
CQEnd =DATE(D2,FLOOR(MONTH(DATEVALUE("1/"&$E2&"/"&$D2))+2,3),30)
Periods =ROUNDDOWN((H2-G2)/90,0)
Drag all three formulas down to apply to all rows.
You can choose to combine the first two formulas into the third one but it will make the formula too long to be easily interpreted and/or edited for future needs.
Here are the main functions used in my solution:
DATE() convert yyyy,mm,dd into a valid date/numerical value for calculations;
DATEVALUE() convert text date dd/mmm/yyyy into a valid date/numerical value for calculations;
FLOOR() work out the start/end month for a given month;
ROUNDDOWN() calculate the number of periods.
Cheers :)

How to use IF with dates by month, excluding specific days

I'm trying to use an excel formula to see if an input date's month is <= today's month by a maximum of 3 (irrespective of day).
The input DAY must also NOT be >= today's date by a maximum of 10.
Then provide a YES or NO output.
I'm relatively new to excel (and coding in general), but I have managed to have it specify if a month is <= to today's month.
But I have hit a wall when it comes to the extra rules above.
Perhaps using two separate IF statements for the DAY and MONTH rules would be easiest, then using an IF AND to join them up in the output cell. I'm just unsure how to put the limiters on the <= and >= operators.
=IF(MONTH(A2)<=MONTH(A4),"YES","NO")
=IF(DAY(A2)>=DAY(A4),"YES","NO")
=IF(B8 AND B9 = "YES","YES","NO")
What I want to achieve is something like this:
Today: 11/04/2019
Input: 10/01/2019
OUPUT: YES
(Input month is less than today's month by 3 months, input day is not equal to or greater than today's day)
Today: 11/04/2019
Input: 20/01/2019
OUPUT: NO
(Month is within 3 months BUT the day is >= today's day)
I think this should work:
=IF(AND(MONTH(C15)>=MONTH(E2)-3;MONTH(C15)<=MONTH(E2));IF(AND(DAY(C15)>=DAY(E2);DAY(C15)<=DAY(E2)+10);"YES";"NO");"NO")
At least it did on my worksheet.
The logic behinds is: First check if the month is equal or greater than today's month AND if its equal or lesser than today's month - 3. If that's not true it just skips to the las "NO". Now let's say the first check returns YESthen again, check if the day is equal or greater than today's day AND is lesser or equal than today's day + 10.
Edit: Since you are toying with Months as numbers you will have a hard time when 3 months means last year. The only way to sort this is going to dates instead months.

Difference between two dates with decimal result

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

Excel Subtracting periods from specific dates using 360-day calendar?

Got formulas for figuring my differences between date periods in days as follows:
=IF(F7="","0",DAYS360(F6,F7)+1)
This gives the days result for each period that I am interested in, but I then need to add each period of days together and subtract them from a current date (like doing service computation). The issue is that I need to do this second calculation within a 360-day calendar as well. If I just try to do a days360() formula with one value being the current date and the other being the total number of days that I need to backtrack, then the "original" date that it comes up with is drastically off.
This seems to be the equivalent of the difference between NETWORKDAYS and WORKDAY functions. The former counts working days between two dates, the latter adds working days to a date, you essentially want the WORKDAY equivalent for DAYS360, which I don't think exists.
You can manipulate DAYS360, though, e.g. with a date in A2 and number of days to subtract (in 360 day mode) in B2 you can use this formula for the date
=A2-B2-MATCH(B2,INDEX(DAYS360(A2-B2-ROW(INDIRECT("1:"&CEILING(B2/30,1))),A2),0),0)

Elapsed Days Hours Minutes Excluding Weekends and Holidays Time

This sounds simple but I have been pulling my hair out trying to figure out a solution. Any help before I go bald would be great.
I need a formula which is able to
calculate the duration in (days, hrs, mins) between two date\time values (eg 05/12/2012 5:30 PM and say 07/12/2012 5:45 PM);
excluding weekends and holidays.
I would like the result of the formula to read as follows "e.g 2 Days 0 Hrs and 15 Mins".
Thanks
Link to sample workbook
You can use NETWORKDAYS and NETWORKDAYS.INTL to achieve this
A bit of manipulation is required as these return net whole days:
Use these functions to calculate the number of non workdays, then subtract from the difference between start and end dates
=E3-D3-(NETWORKDAYS.INTL(D3,E3,"0000000")-NETWORKDAYS(D3,E3,$A$16:$A$24))
This returns the working day difference, where 1.0 = 1 day
NETWORKDAYS.INTL(D3,E3,"0000000") calculates whole days between the two dates (no weekends, no holidays)
NETWORKDAYS(D3,E3,"0000000",$A$16:$A$24) calculates whole working days days between the two dates (Sat/Sun weekends, holidays as per your list in $A$16:$A$24)
Difference in non-working days between the two dates.
E3-D3 is time between start and end date/times (1.0 = 1 day)
Use custom number formatting to display thye result in the format you require
d "Days" h "Hours" mm "Mins"
Note: this format won't work for negative values, you will need an alternative for when end date is before start date.
The following formula works like a treat with no additional formatting or manipulation.
To make it more stable I have turned all the holiday dates for UK 2012/13 into ‘Excel Serial Number’ format and placed them in an array bracket.
Replacing the "D5" in the formula with your cell reference for your course or metric "End Date" and "E5" with your course or Metric for "Completion Date".
=IF(E5<D5,"-"&TEXT(D5-E5,"h:mm"),NETWORKDAYS(D5,E5,({40910,41005,41008,41036,41064,41065,41148,41268,41269,41275,41362,41365,41400,41421,41512,41633,41634}))-1-(MOD(E5,1)<MOD(D5,1))&" days "&TEXT(E5-D5,"h:mm"))

Resources