Comparing Month with date(MM/DD/YR) - excel

Is it possible to compare a month number with a date(MM/DD/YR) in Excel/Google Sheets?
For example, according to the screenshot, I just want to calculate the weekly time only in September and not August. I want it to be general so whatever month I choose, it will only calculate the hours for that month and not other months that is displayed on the table. I think the way to approach the problem is writing an if statement where if the DATE column starts with "9", then it will only calculate that row, and ignore the other rows that is not a 9.
I am just not sure if we can compare multiple cells to see if it matches with a certain month.

all you need is:
=SUM(FILTER(B1:B7, MONTH(A1:A7)=8))

You could use SUMIFS in both Excel or Google Sheets:
=SUMIFS(E2:E8,A2:A8,">="&F10,A2:A8,"<="&EOMONTH(F10,0))
Adjust ranges (and make them absolute if need be)

Related

How do I sum a total number of occurrences of a ID number with a specific month and year in Excel

I have a Excel Master sheet where I am looking to query other sheets within the workbook. What I am trying to do is see How many occurrences of an ID for a Project in a column occur within a month, e.g. how many times does the ID 1367 occur in November. My dates are in the format of e.g 13/11/18 and this cannot be changed as I am just creating a report against a workbook I do not own.
The relevant columns I need are formatted like so:
Project: Project ID: Date:
a 123 1/01/2018
a 123 2/01/2019
a 123 3/01/2018
a 123
This is my SUMIFS function:
=SUMIF(PPlanner!$D:$D,Dashboard!$B$6,PPlanner!X:X)
This works by itself. My problem is trying to get the ID total for a specific month.
It returns the number of occurrences the ID occurs against a project all together but not against the month specifically. I have tried adding syntax to specify
the month but I am getting errors such as "too many arguments".
I recently answered a question that was very similar :
Excel - Take Average of Monthly Data
I think this would answer your question as well, but you have to use COUNTIFS instead of AVERAGEIFS
As for presentation, I would make a separate list of the months you want to include, and put the formula next to it, instead of the formula next to the actual list of data (as in the other question). As for how to write/input the month, you can put it any way you want, as long as it is a valid date in Excel. With the cell formatting you then can show it as month and year only. This is just to say that a text input JANUARY 2018 does not work (in a normal cell, eg. a cell that you did not format as text, when you type that into the cell, Excel recognizes this as a date, and will actually put 1/1/2018).
Oh, and using a Pivot table would work as well, the other answer on the question referenced above also explains how to do that.
In some cases, how Excel handles dates is very convenient.
For you, the date format doesn't matter. It is simply a number counting days with 0 being December 31st, 1899.
13/11/18 the date is the integer 43417 in-cell value. Excel interprets this as a both date and time together. The whole numbers are the days while the decimals are the time of day as a fraction of the day. 43417.5 would be noon.
So you may use COUNTIFS to help here.
=COUNTIFS(PPlanner!$X:$X, 1367, PPlanner!$D:$D, ">"&43404, PPlanner!$D:$D, "<"&43435)
This is going to look at sheet PPlanner column X and count how many instances of 1367 occur after the last day of October and before the first day of December. There are other ways to accomplish this, but it allows you to count within any date range you want.

Guide me Regarding Compare the Value of Cell contain date and other cell contain Drop down list

Hy Every One, I need help in excel formula, I have two sheets, sheet1 for sale tracker, sheet two for goals tracker, I used Now() to enter date automatically, and its working fine, Next in goal sheet, I use =Sumif() to calcualte various category totals and refer them in cell. Its also working fine. But I want to track record according to month and category. Like I have 6 categories detail is as under,
Sales Tracker
In the First picture Column Date consist of formula "=IF(ISBLANK(B5),"-",TODAY())" and it display the name of month like "October"
While in second picture there is a drop down list of "Month" Column.
1- I want to use if statement like =if(Date=Month, Sum(Revenue Secure column Data), "-") But its not working the formula I wrote here is an example....
2- I want when I select any month from second sheet like January, February, It should calculate sum from picutre one data and only show the sum of january etc.
Please help me, this is eating my brain a huge,,,,,,:)
Thanks in advance....
In short my question is how can I use If statement to compare value of cell that contain formula and other that contain drop down list?
Or use the MONTH function to change your date to a number 1 to 12 corresponding to the month. Then have the combo return a number for the month chosen. It might be faster using integers than test
I Believe you have to compare the month and not the whole date.
You can do TEXT(NOW();"mmmm") to get the full month name of the current data (in the language of excel) and then compare it to your drop down.
If you replace the NOW() with any data it works as well.

How to compare two dates and take one that is smaller? e.g MIN for DATE

This question is for educational purposes only, as I have already solved this problem in a way I dislike...
Sheet looks following and has rows for months, in each row there is a column for days that month and for current month
I have a formula that calculates how many days have passed this month or month that has passed which is used in some later calculations.
=TODAY()-DATE(2017,6,1)+1
Currently at the end of month I have to go and change formula to (as they go over 31 day in a month)
=DATE(2017,5,31)-DATE(2017,5,1)+1
What I would like to do is something like:
=MIN(TODAY(),DATE(2017,6,30))-DATE(2017,6,1)+1 to take whichever date is less, so I could do the formulas for the months in advance and not need to go back to it at the end of every month...
I can do it like =MIN(TODAY()-DATE(2017,6,1),DATE(2017,6,30)-DATE(2017,6,1))+1 but it looks somewhat not nice...
How do I compare two dates and take one that is smaller?
After a chat room discussion, it appears that one problem was the formatting of the results.
So =MIN(TODAY(),DATE(2017,6,30))-DATE(2017,6,1)+1 is sufficient
Excel stores dates as serial numbers with 1 = 1-Jan-1900.
If one wants to return a date, the cell containing the formula should be formatted as a date.
If one wants to return a numeric value, the cell containing the formula should be formatted as General or as a number with the appropriate number of decimals.
Excel does not always format the cell as desired by the user, so this may need to be edited.
Days passed for that month is nothing but the day. You can directly use the below formula, I believe.
=min(day(date(2017,6,30)), day(DATE(2017,6,4)))
if you want that as a date. Then you can include another date function to include month and year. If you just want the smaller date itself, then you can directly use the date itself in the min function
=min(date(2017,6,30), date(2017,6,4))
You have TODAY() function to get today date, you can get this month by MONTH function in excel.
TODAY() - DATE(2017, MONTH(TODAY()), 1) + 1
reference
If you want to know how many days have passed, can't you just use
=TODAY()-(EOMONTH(TODAY(),-1)+1)

Excel: Trying to count cells based on date, can't figure out SumIf

hopefully you can help me with this. I've been trying to figure it out in Excel myself, but I can't make the functions work and it's causing me to manually count the cells.
I've created a sample sheet on Google to show roughly what I'm trying to do;
https://docs.google.com/spreadsheets/d/18bFBvtbK-3JDj6Z6_b6NHttaytApNvdfw92ZcI4ECws/edit#gid=0
I have a series of tests my personnel have to take annually, and I want to write a function that displays the total number of tests taken within the past year. Cell B1 would be the column title, B2-4 would display the date the test was taken, and B5 is where I want the number of dates in B2-B4 that are less than one year old.
Any ideas?
If you want less than a year old from todays date then just count all values that are greater than 365 days ago,
=COUNTIF(B2:B4, ">"&(TODAY()-365))

Excel SUMIF between dates

I have column A with date values formatted as mm/dd/yyyy. I am trying to sum the values of column B if A >=DATE(2012,1,1) AND
=SUM(B:B) sums B properly, but if I try to use =SUMIF(B:B,A:A>=DATE(2012,1,1)) the value returned is 0.00. I'm assuming this has something to do with using decimal for the sum and date type for the criteria. Is there a way to get around this?
Thanks
You haven't got your SUMIF in the correct order - it needs to be range, criteria, sum range. Try:
=SUMIF(A:A,">="&DATE(2012,1,1),B:B)
To SUMIFS between dates, use the following:
=SUMIFS(B:B,A:A,">="&DATE(2012,1,1),A:A,"<"&DATE(2012,6,1))
I found another way to work around this issue that I thought I would share.
In my case I had a years worth of daily columns (i.e. Jan-1, Jan-2... Dec-31), and I had to extract totals for each month. I went about it this way: Sum the entire year, Subtract out the totals for the dates prior and the dates after. It looks like this for February's totals:
=SUM($P3:$NP3)-(SUMIF($P$2:$NP$2, ">2/28/2014",$P3:$NP3)+SUMIF($P$2:$NP$2, "<2/1/2014",$P3:$NP3))
Where $P$2:$NP$2 contained my date values and $P3:$NP3 was the first row of data I am totaling.
So SUM($P3:$NP3) is my entire year's total and I subtract (the sum of two sumifs):
SUMIF($P$2:$NP$2, ">2/28/2014",$P3:$NP3), which totals all the months after February and
SUMIF($P$2:$NP$2, "<2/1/2014",$P3:$NP3), which totals all the months before February.
this works, and can be adapted for weeks or anyother frequency i.e. weekly, quarterly etc...
=SUMIFS(B12:B11652,A12:A11652,">="&DATE(YEAR(C12),MONTH(C12),1),A12:A11652,"<"&DATE(YEAR(C12),MONTH(C12)+1,1))
One more solution when you want to use data from any sell ( in the key C3)
=SUMIF(Sheet6!M:M;CONCATENATE("<";TEXT(C3;"dd.mm.yyyy"));Sheet6!L:L)

Resources