Excel determine previous Month and Year from an existing date - excel-formula

I have a date field 7/12/2016 and I need to extract the previous Month Year from this date. What is the best formula?
Needed format of final data Jun-2016

If you need to return it as date, use DATE, YEAR and MONTH function combination.
=DATE(YEAR(DateField), MONTH(DateField)-1, 1)
Then use Custom Number Format: mmm-yyyy
Note: DateField should be the cell reference containing your actual date.

Previous Month name using sharepoint calculated column as follows
=TEXT(DATE(YEAR([Due Date]),MONTH([Due Date])-1,"1"),"MMMM")

Related

Excel DATE IF Condition

Excel formula required as per the following conditions:
Conditions:
After Date after 31/07/2017
Before Date after 12/10/2016 & Before 01/08/2017
Old Date after 12/10/2015 & Before 12/10/2016
Very Old Date Before 12/10/2015
Output as follows
Date Status
12-03-2014 Very Old
10-03-2015 Very Old
11-02-2016 Old
05-05-2016 Old
22-12-2016 Before
25-01-2017 Before
28-02-2017 Before
20-03-2017 Before
19-06-2017 Before
20-07-2017 Before
21-07-2017 Before
10-08-2017 After
25-08-2017 After
29-08-2017 After
01-09-2017 After
08-09-2017 After
Please help
CSGanesh
Create a table with the start dates and the expected outcome:
Then use VLOOKUP()
=VLOOKUP(D2,A:B,2,TRUE)
If you do not want to use a table but want hard-coded formula then:
=CHOOSE(MATCH(D2,{0,42289,42655,42947}),"Very Old","Old","Before","After")
{0,42289,42655,42947} are the dates in general format and can be replaced with the actual dates in quotes; {"1/0/1900","12/10/2015",...}
I would use a nested if statment here is a link:
https://exceljet.net/formula/nested-if-function-example
here are the first two conditions, excel can interpret time intervals so lock a cell with the conditions and then drag the formula. Remember to verify that the cell is indeed a date.
IF(date<12/10/15,"Very old",IF(AND(D6>12/10/15,date<12/10/16),"old",0))

Excel Return Date before another date by another column name

I have two sheets of data with the following.
I want return the date from sheet 2 on sheet 1 with the start date BEFORE the remove date. For example. For Customer A, the remove date is 12/29/2016. I would want to return the date of 12/20/2014 from sheet 2 as it is the next previous date from the remove date of 12/29/2016 from sheet 1 and is removed prior to the third date of 1/20/2017. Similarly for Customer B, the date returned would be 11/9/2013.
Vlookup will not work as there are more than one unique value for customer and I had no luck with index and match. Is there any other possible solution?
Here is an edit. The Sumproduct and aggregate method for the start date works great. The issue is I need the last date to be the first record after the replacement date. So in this case, it would be 2/1/16. Using the Min or Max sumproduct and aggregate method, I get either 0 or the max date of 3/22/17, which is not what I want.
Since dates are (for all intents and purposes) numbers, this is really nothing more than a pseudo-MAXIFS question. Try,
=aggregate(14, 6, (b2:b7)/((a2:a7="A")*(b2:B7<date(2016, 12, 29))), 1)
For those that don't have the latest version of excel and can't use maxifs, we can do an array formula: take the max date that is less than the date corresponding to A
=SUMPRODUCT(MAX((A9:A14=A3)*(IF((B9:B14)<B3,B9:B14))))
entered as array formulae (Ctrl+Shift+Enter)

How to substract dates with excel - current date with date in format yyyyddmmhhmmss

Is there any option to compare dates with Date format yyyymmddhhmmss with the current date?
Basically one of my external source have this type of date and I have to compare this date with the current date and check difference in between. I have tried to split those date with LEFT,MID,RIGHT functions, so basically, I have two columns - first with date, second with time, but I cannot find any option to subtract current date with date in column, because results are not coming correct.
Sample of date: 20161112203545
after splitting: 2016-11-12 20:05:45.
Any ideas?
Image produced below with formulas is self explanatory.
Your date :20161112203545 in D4
Formula to convert date in E4 :
=DATE(LEFT(D4,4),MID(D4,5,2),MID(D4,7,2))+TIME(MID(D4,9,2),MID(D4,11,2),RIGHT(D4,2))
Today's Date in F4 : =TODAY()
Formula to get date difference in days in G4 : =DATEDIF(F4,E4,"d")
EDIT
The alternative to Excel DATEDIF would be a User defined function (UDF) that internally uses the VBA DATEDIFF function:
This UDF accepts three parameters:
Start_Date: The days from which the period begins.
End_Date: It is the last date of the period that you wish to calculate.
Unit: It specifies the interval by which you want the difference. Here the unit accepts following values.
Value Description
YYYY Year
Q Quarter
M Month
Y Day of year
D Day
Public Function xlDATEDIF(Start_Date As Date, End_Date As Date, Unit As String) As String
xlDATEDIF = DateDiff(Unit, Start_Date, End_Date)
End Function
In this case usage will be, put formula in H4 =xlDATEDIF(F4,E4,"D")
HTH
Taking the date as
20161112203545 after splitting: 2016-11-12 20:05:45
Is going to cause you some issues as Excel assigns date values with a serial number, and it's going to throw that number off. You could use the =today() function and set it up where you have the date entered, say it is in cell A1, then =A1-today() (formatted as a number) should give you the difference in the amount of days.
Microsoft explanation of using Dates in Excel

Excel: Convert calendar week (format ww.yyyy) into date

I need to convert an Excel calendar week date into the actual date.
Excel calendar week format = ww.yyyy (e.g. 31.2014);
Expected output = 7/28/2014 (return the Monday of the week)
What formula should I use ?
It's a bit of a pain: there's no direct function. If A1 contains the year, and A2 contains the week number then,
=MAX(DATE(A1,1,1),DATE(A1,1,1)-WEEKDAY(DATE(A1,1,1),2)+(A2-1)*7+1)
will return the date corresponding to the Monday of that week in that year.
To test it, use =WEEKNUM() and =YEAR() on the computed result, along with =TEXT(,"DDD") to prove it's a Monday.
If #Bathsheba's response works for you, you can do everything in cell B1 with the following command
=MAX(DATE(LEFT(B1,FIND(".",B1)),1,1),DATE(LEFT(B1,FIND(".",B1)),1,1)-WEEKDAY(DATE(LEFT(B1,FIND(".",B1)),1,1),2)+(MID(B1,FIND(".",B1)+1,2)-1)*7+1)
This allows you to put YYYY.WW in B1 and it splits it up for you in the calculation.

Check if any date within a range is within 1 month of todays date

I've got a column full of dates. How can I check that column to find which date is within a month of todays date, and then return it?
If there is no date within a month, just return blank
Lets say my dates are:
01-Jan-12
01-Apr-12
01-Jul-12
01-Oct-12
01-Jan-13
The code im using is below. A:A is the range of the dates above
=MIN(IF(A:A>TODAY(),A:A))
The issue im having is that if I use the above, it returns 01/01/12 and not 01/01/13. Also, if I change the dates so the next date is December 1st 2012, it still returns 01/01/12
So you really just want the earliest date if that's within a month? If so perhaps try
=IF(MIN(A:A)-TODAY()<=30,MIN(A:A),"")
Assumes dates in column A
If you have past and future dates try this formula
=IFERROR(SMALL(IF(A2:A100>=TODAY(),IF(A2:A100<=TODAY()+30,A2:A100)),1),"")
confirmed with CTRL+SHIFT+ENTER
or for exactly 1 month (rather than 30 days) try using EDATE, i.e.
=IFERROR(SMALL(IF(A2:A100>=TODAY(),IF(A2:A100<=EDATE(TODAY(),1),A2:A100)),1),"")

Resources