Microsoft Excel Array Formula with dates

2019-09-05 21:41发布

问题:

I need the following array for a Date type:

=IF(OR(A2:C2="Mar 12"),1,0)

Sample Data https://docs.google.com/spreadsheet/ccc?key=0AhoDU0OTM87sdHR3RGw3NTJacEV1OEt5OWZTWTBYUFE&usp=sharing

Looking at the sample data, in Column E I want an array formula that would look into columns B to D and search for results that contain 'May 12' and display true or false (1 or 0) in column E.

回答1:

I think this will meet your needs - type in D2:

=IF(SUM((MONTH(A2:C2)=5)*(YEAR(A2:C2)=2013))>0,1,0)

but press CTRL+SHIFT+ENTER instead of usual ENTER - this will define an ARRAY formula and will result in {} brackets around it (but do NOT type them manually!).

Specify month and year as you wish)



回答2:

I think this is what you're looking for (noticed the date format was dd/mm/yyyy so I adjusted):

=IF(COUNTIF(A1:C1,"12/5/2013")>0,TRUE,FALSE)

Edit:

For just month and day:

=IF(SUMPRODUCT((MONTH(A1:C1)=5)*(DAY(A1:C1)=12))>0,TRUE,FALSE)

Month and year:

=IF(SUMPRODUCT((MONTH(A1:C1)=5)*(YEAR(A1:C1)=2012))>0,TRUE,FALSE)