Microsoft Excel Array Formula with dates

限于喜欢 提交于 2019-12-25 11:33:12

问题


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)


来源:https://stackoverflow.com/questions/14733602/microsoft-excel-array-formula-with-dates

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!