student programmer
student programmer

Reputation: 53

Comparing Month with date(MM/DD/YR)

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.

enter image description here

Upvotes: 1

Views: 190

Answers (2)

player0
player0

Reputation: 1

all you need is:

=SUM(FILTER(B1:B7, MONTH(A1:A7)=8))

0

Upvotes: 1

JvdV
JvdV

Reputation: 75950

You could use SUMIFS in both Excel or Google Sheets:

=SUMIFS(E2:E8,A2:A8,">="&F10,A2:A8,"<="&EOMONTH(F10,0))

enter image description here

Adjust ranges (and make them absolute if need be)

Upvotes: 1

Related Questions