问题描述
我使用带有公式的条件格式来突出显示今天(或过去)中某些颜色的日期。为了检查今天是否发生日期,我只需使用 A1 = TODAY()
,这样可以正常工作。但是,某些单元格包含数据时间,例如 25-Mar-2014 11:14 PM
。当我在该单元格上使用上述公式时,即使今天是3月25日,它返回 FALSE
。
I am using conditional formatting with formulas to highlight dates that occur today (or in the past) in some colour. To check whether a date occurs today, I simply use A1=TODAY()
, which works fine. However, some cells contain datetimes, such as 25-Mar-2014 11:14 PM
. When I use the above formula on that cell, it returns FALSE
, even though today is the 25th of March.
确定日期时间是否在今天发生的正确方法是什么?我尝试使用 DATE(A1)
将单元格转换为没有时间的日期,但这不起作用。我不想使用Visual Basic,也不要像 AND(A1< tomorrow; A1>昨天)
。
What is the correct way to determine whether a datetime occurs today? I have tried using DATE(A1)
to convert the cell to a date without time, but that does not work. I do not want to use Visual Basic for this, nor do something like AND(A1<tomorrow;A1>yesterday)
.
推荐答案
事情是 DATE
不像你所说的那样使用。它是这样使用的:
The thing is that DATE
is not used like you mentioned. It is used like so:
=DATE(year, month, date)
您可以使用 INT
将其舍入到最接近的整数(所以 2014年3月25日11:14 PM
成为 2014年3月25日00:00:00
就像今天()
You can perhaps use
INT
which rounds down to the nearest integer (so 25-Mar-2014 11:14 PM
becomes 25-Mar-2014 00:00:00
just like TODAY()
):
=INT(A1)=TODAY()
这篇关于Excel:将DateTime与Date对比的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!