简体   繁体   English

检查人员的生日是否在Microsoft Excel 2003中的特定日期之后

[英]Checking If A Person's Birthday is after a specific date in Microsoft Excel 2003

How can I check if a person's birthday is after the 15th of any month in MS Excel 2003? 如何在MS Excel 2003中检查一个人的生日是否在任何月份的15日之后? If the birthday is after the 15th, then the first date of the next month should be displayed. 如果生日是在15日之后,则应显示下个月的第一个日期。 If it's before the 15th, then the first date of that month should be displayed. 如果它在15日之前,则应显示该月的第一个日期。

=DATE(YEAR(A1);IF(DAY(A1)<=15;MONTH(A1);MONTH(A1)+1); 1) =日期(年(A1); IF(日(A1)<= 15;月(A1);月(A1)+1); 1)

you may have to substitute comma to semicolon, depending on your locale 您可能需要将逗号替换为分号,具体取决于您的语言环境

(it is very convenient that the function DATE could take month=13 and increment the year) (功能DATE可能需要一个月= 13并增加年份非常方便)

Be careful at the end of the year! 在年底要小心!

=MONTH("31.12.2013") + 1 will return 13! =月(“31.12.2013”​​)+ 1将返回13!

Better you use the EOMONTH function. 最好使用EOMONTH功能。 Assuming the The bithday date is stored in D9: 假设bithday日期存储在D9中:

=IF(DAY(D9)<=15;EOMONTH(D9;-1) + 1;EOMONTH(D9;0)+1) = IF(DAY(D9)<= 15; EOMONTH(D9; -1)+ 1; EOMONTH(D9; 0)+1)

Could be like this: 可能是这样的:

 =IF(DAY(A1)>15;DATE(YEAR(TODAY());MONTH(A1)+1;1);DATE(YEAR(TODAY());MONTH(A1);1))

The birthday date is in A1 . 生日日期是A1

Not clear what should happen if birthday is exactly 15th? 不清楚生日到底是什么时候会发生什么? Next month or this month? 下个月还是本月? Either way you can subtract 15 and then find the end of the month and add 1, ie using EOMONTH function 无论哪种方式,您可以减去15然后找到月末并添加1,即使用EOMONTH函数

=EOMONTH(A1-15,0)+1

or avoiding EOMONTH (because it requires Analysis ToolPak in Excel 2003) you can use 或者避免使用EOMONTH(因为它需要Excel 2003中的Analysis ToolPak)

=DATE(YEAR(A1-15),MONTH(A1-15)+1,1)

If birthday is on 15th both of those will give current month - if it should be next month for exactly 15th then change instances of -15 in formulas to -14 如果生日是在15日,那么这两个将给出当前月份 - 如果它应该是下个月正好15日,那么将公式中的-15的实例更改为-14

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM