In excel, I have a table that contains dates in the format mm/dd/yyyy. I am trying to gather some stats on this table, more specifically how many there are from a month number that is stored in another cell and the current year. So for example if the value in the other cell was 1 and the current year was 2015 I would want to return the number of dates from January 2015. Would this be possible by a count if statement? Any help with this issue would be greatly appreciated.
With A1 being the cell containing the Month number, try:
=COUNTIFS(TableDateColumn,">="&DATE(YEAR(TODAY()),A1,1),TableDateColumn,"<"&DATE(YEAR(TODAY()),A1+1,1))
Related
I have the results of a survey with birthdays in various date formattings.
01.01.1990
02/03
04.05 etc.
Every time Excel sees a day and a month without a year it implies the current year and puts it in the cell without any hesitation. So, when we try to extract a year, we get not the error we expected but the current year, which is nonsense.
How can we avoid this behaviour?
The desireable result is:
One column with one formula
If the year is written, we extract it using =YEAR()
If it is absent, we just do anything else, for instanse put "".
Basic change of formatting doesn't change the implication of the current year. And if we change the format of the whole column from date to text, we cannot use the formula "YEAR" anymore to any of the cells.
This is a task for students who can deal with Excel and Google Sheets only, Python is not an option.
I would be very grateful for any help!
Both Excel and Google Sheets stores date as a number (day count) starting from 1900/01/01 so it either assumes year for you or doesn't recognize it as date at all.
If you convert date to number, 1900/01/01 will be 1, 2023/01/16 will be 44942 (as it is 44942 day counting from 1900/01/01).
I assume that survey can't be filled by people born this year so just "filter" them out:
If date is in A1 use formula:
=IF(OR(YEAR(A1)=2023,YEAR(A1)=1900),"",YEAR(A1))
This will print nothing if captured year is 2023 or 1900 (this behavior also possible when dealing with dates without years).
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 am trying to establish the best way to write a formula to take a date that is inputted in a cell by a user and subtract it from the last day of the month (the due date), not taking into account what year it is. The cell that contains the formula will be in another cell, pointing at the user inputted date cell.
I have 12 columns running across with each with one of the months of the calendar year. In each column for the corresponding month is where the user will input the date they completed a task. I would like to subtract their input from the last day of the corresponding month in that column. I want to reuse this spreadsheet every year, so I do not want to account for the year in my formula. I hope this will prevent me having to update the formulas each year.
An example would be if the user inputted 2/24/17 into C7, because the column C is the column for February, I would like the result to be -3 (I am not worried about leap years at this point). If they inputted 3/11/17 into the same cell (C7), they would get a result of 11, because the date is 11 days past the due date.
Here is the formula that I started to use, but I believe it is relative to the current year.
=IF(ISBLANK(C7),"",C7-(DATE(YEAR(TODAY()),MONTH(1)+2,1)-1))
Here is a link to a picture of my spreadsheet. Thank you in advance for your help!
Solution
Changed YEAR(TODAY()) to YEAR(target cell). My new formula looks like:
=IF(ISBLANK(C7),"",C7-(DATE(YEAR(C7),MONTH(1)+2,1)-1))
Maybe:
=IF(C7="","",C7-EOMONTH(C7,-1))
(based on #barry houdini's Comment and subsequent OP clarification via a Comment).
Using excel, is it possible to specify the month to report in a cell?
For example, excel would need to report the latest reported sales, if its available. If the month of February sales is not available, then it will report January sales. Likewise, if March sales is available, it would report the sales in March.
How do you write this formulae in a cell in excel? If its not possible to write such a formuale, can we write a vba to do this?
If you mean you have a list of sales entries and want the sales for the last month in the data, you could write one formula to get the latest month. If months are in A you could write: =month(max(A1:A99999))
Note if you have multiple years data, you need to pull the year too or get bounding dates. You can then sum sales using an array formula like assuming the result of the first action is in D1 and sales are in B: {=sum(if(month(A1:A999999)=D1,B1:B999999,0))}
If you have incremental updates during the month, this will return month to date data. If you need data for the last full month, you can use another array formula to get the maximum month where the date is the last day of the month.
If the cells for future data in B1:B12 are blank then you just need to extract the last number in B1:B12 don't you? If so then try
=LOOKUP(9.99E+307,B1:B12)
You can use the OFFSET function to select specific data based on the month.
Insert a formula to calculate the current month (or just type in the month number)
=MONTH(TODAY())
The formula to select the current months of sales data
=SUM(OFFSET(B1,MONTH(TODAY()),0,1,1))
Have a look at the help in Excel on the OFFSET function. It can be used to select a range of data. For example, to return data from the start of the year to the current month the formula would be:
=SUM(OFFSET(B1,1,0,MONTH(TODAY()),1))
If the current month does not contain data yet, you can test to see if a value is returned and revert to the prior month if there is no data.
=IF(SUM(OFFSET(B1,B16,0,1,1))=0,SUM(OFFSET(B1,B16-1,0,1,1),SUM(OFFSET(B1,B16,0,1,1))))
I found this answer:
=IF(B12<>0,B12,IF(B11<>0,B11,IF(B10<>0,B10,IF(B9<>0,B9,IF(B8<>0,B8,IF(B7<>0,B7,IF(B6<>0,B6,IF(B5<>0,B5,IF(B4<>0,B4,IF(B3<>0,B3,IF(B2<>0,B2,IF(B1<>0,B1,0))))))))))))
This formulae solves the problem of picking up the latest available data.