I'm trying to construct an Excel formula which compares the date in column A to the date in column B and tells me YES if they are the same date, tells me NO if they are different dates, then if NO tells me what is the oldest of the two dates.
What I have is not working:
=IF(A1=B1,"YES","NO"&(A1,B1))
=IF(A1=B1,"YES","NO "&TEXT(MIN(A1,B1),"mm/dd/yyyy"))
Or if you just want the oldest date without the "NO" then do this (be sure to format cell as date):
=IF(A1=B1,"YES",MIN(A1,B1))
Related
I am trying to calculate the totals of a column when the date column is within a certain month. The value to find is in a different date format to the format in the criteria range and I can't figure out how create a formula using the two different date formats. Here are the columns where I am trying to get the totals from:
Here is where I am trying to count the rows when it falls within a certain month and year:
This is the formula I have created but this doesn't work and just returns 0:
=COUNTIFS($A$3:$A$27, YEAR(G3), $A$3:$A$27, MONTH(G3))
I have also tried this but it is still returning 0:
=COUNTIFS($A$3:$A$27, "=YEAR(G3)", $A$3:$A$27, "=MONTH(G3)")
Format is irrelevant if your dates are REAL dates
If your dates are "real" dates, merely formatted a certain way
And if your Months are also real dates where the date is actually the first of the month,
Then:
=COUNTIFS(Dates,">="&B15,Dates,"<=" &EOMONTH(B15,0))
Where Dates is the Named Range containing your list of dates, and B15 contains your month/year formatted first of the month date.
If your months column is not the first of the month, then a minor change is all that is needed to convert the first criteria to the first of the month:
=COUNTIFS(Dates,">="&DATE(YEAR(B15),MONTH(B15),1),Dates,"<=" &EOMONTH(B15,0))
I am trying to get the number of days per year between two dates.
The results should look somehow like the following picture
The range between the 2 dates in the 2021 year has 301 days and in the 2022 year has 94 days.
Put this in C2 and copy over:
=MIN(DATE(C1,12,31),$B$2)-MAX(DATE(C1,1,1),$A$2)
Your question isn't entirely easy to understand but what you don't know is in plain sight: Excel represents dates as integer numbers where Jan 1, 1900 is the first day (= 1) and all days from then till now have a unique number. Today is 44261. Tomorrow will be 44262.
Therefore the difference between dates equals [End date] - [Start date], where only one of these two dates is included in the count. [Tomorrow]-[Today] = 1, not 2.
When a worksheet cell is formatted as General Excel will automatically change that format to whatever Excel thinks you have probably entered. If you enter what Excel recognizes as a date the cell format will be changed to Date and if the way you entered the date was by function, such as =TODAY() the cell will display "6/3/2021" using the date format specified in your Windows International settings.
But if you manually change the cell format back to General or Number the display will change to 44262. That's the way you can test if your cell contains a "true" date, with which you can do calculations, or a "fake" date, which is just a text string which is nice to look at but otherwise useless.
I'm trying to run a formula that essentially compares two different date columns to determine if another formula needs to be run but I'm running into trouble because the dates are in different formats. For example, I have column A with dates in DD-MMM-YY format and column B where the dates are in QYY format.
DATE INCOME_QTR STATUS
22-Feb-05 1Q18
13-Oct-17 1Q18
29-Apr-08 1Q18
03-Oct-16 1Q18
05-Apr-19 1Q18
02-Mar-15 1Q18
Essentially I want to do an IF statement to determine if the date in column A is greater than or equal to the quarter to determine if the data tied to the first date should be incorporated into the Quarter shown in column B. In simpler terms, only row 6 would be "yes" in this case because the date in column A is greater than the Quarter in column B.
I've been trying to run =IF(TEXT([#[date]],"YYYYMMDD">TEXT([#[income_qtr]],"YYYYMMDD")),"YES","No") but I haven't been successful.
Ideally I'd like to be able to do this without adding any modules or using VBA.
Thanks for your help!
=IF(RIGHT(A1,2)>RIGHT(B1,2),"Yes",IF(RIGHT(A1,2)<RIGHT(B1,2),"No",IF(IF(OR(MID(A1,4,3)="Jan",MID(A1,4,3)="Feb",MID(A1,4,3)="Mar"),1,IF(OR(MID(A1,4,3)="Apr",MID(A1,4,3)="May",MID(A1,4,3)="Jun"),2,IF(OR(MID(A1,4,3)="Jul",MID(A1,4,3)="Aug",MID(A1,4,3)="Sep"),3,4)))>=RIGHT(B1,1),"Yes","No")))
That's the formula for A1 and B1...
In Excel VBA, i'm trying to read a date from a cell. The cell contains the date in the form "dd.mm.yyyy" (I'm in Germany). What I need specifically is the month. But when trying to read the month, Excel returns "12" every time. By trying Day() and Year(), I found out that the cell is recognised as blank cell and thus only returns the date of 12/30/1899, when obviously the date is entered correctly.
So this is what I'm trying to do which doesn't work (to put it as simply as possible):
ActiveSheet.Range("K2") = Month(B2)
And there you go, I get a "12" in K2, when the date is actually 02.02.2016.
You need to understand that Excel stores dates as numbers, which are formatted to appear like dates in the current locale. The earliest date Excel can show is 1/1/1900, which is the number 1 in General format.
The date 15-July-2016 is the number 42566. That is the number of days since 1/1/1900.
To establish if a cell contains a real date, try formatting it with a different number format. Once you've established that it is a number and can be formatted as a date, you can move on to the next troubleshooting step.
You're not referencing cell B2 correctly. Try
ActiveSheet.Range("K2") = Month(ActiveSheet.Range("B2"))
I want to subtract 2 dates in Excel but the problem is they have different date formats.
So... my first date is something like this 18.09.2011 (DD.MM.YYYY) and the second one is something like 9/15/2011 (MM/DD/YYYY). So how can I subtract these two dates? Because DAY(cell of date one) - DAY (cell of date 2) won't work.
Thanks!
If your dates are really entered as dates you can use them in any kind of calculation, as a date really is stored as a numeric value. Displaying one date in "MM/DD/YY" and the other one in "DD.MM.YYYY" doesn't make a difference. Try to format the cells as "General". Does the display change to a number (e.g. 40801 for today) you're fine. If your dates are entered as strings you may want to convert them into dates first - see this post