Excel公式 - 日期比较


0

我正在尝试构建一个Excel公式,将A列中的日期与B列中的日期进行比较,告诉我,如果它们是相同的日期,则告诉我,如果它们是不同的日期则告诉我,如果否则告诉我是什么两个日期中最古老的。

我有什么不工作......

= IF(A1 = B1, “YES”, “NO” 及(A1,B1))


它可能会消化不良(A1,B1)。它是两个值,没有描述如何处理它们。如果你想要最旧的,请尝试= IF(A1 = B1,“是”,“否”和最小值(A1,B1))
fixer1234

Answers:


3

以下Excel公式应该可以满足您的需求:

=IF(A1=B1, "YES", "NO - " & TEXT(MIN(A1,B1), "m/d/yyyy"))

这个公式说: if the values in A1 and B1 are equal, print YES in the current cell, otherwise print 'NO - ' appended with the lowest value of the 2 cells 'textualized' as a date in the format of 'm/d/yyyy'

MIN 函数将返回2个值(或您的情况下的日期)中的较低者作为序列化日期(即正常数字)。要将其显示为日期值,我们可以使用 TEXT 函数以我们指定的格式打印序列号作为日期(在本例中为“m / d / yyyy”)。

例:

| |     A    |      B    |       C       |
|1| 1/1/1970 | 1/1/1970  | YES           |
|2| 1/1/1970 | 1/20/1970 | NO - 1/1/1970 |

C2 在这个例子中,如果我们没有 TEXT 指定的功能(刚才 MIN )它会打印 NO - 25569

请务必更新公式的单元格引用(即 A1B1 应该 A2B2 等等)。

希望能有所帮助。


接得好。我只是在看为什么原来的配方不起作用。 +1
fixer1234
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.