当前位置: 动力学知识库 > 问答 > 编程问答 >

Google sheets compare times

问题描述:

In a spreadsheet I want to compare a time with now()

I want with a conditional format cell colors red when the time is due

But i noticed there is no way google sheets let me compare with a condition a given time with now. (See example in the link where I use 3 give times)

What is the proper way to compare a time with now()

A1 = 10:15

A2 = 10:20

now() => 10:10

if (now()>A1;TRUE;FALSE)

**output TRUE, expected value FALSE

if (now()>A2;TRUE;FALSE)

**output TRUE, expected value TRUE

Spreadsheet

网友答案:

Now() has a date element it is today. While the times do not. So it will always be greater.

You need to remove the date which is a whole number. One method is:

=MOD(NOW();1)

So your formula will be:

=IF(MOD(NOW();1)>A1;TRUE;FALSE)

One note: if all you want is True/False then you do not need the IF():

=MOD(NOW();1)>A1

Which will return TRUE or FALSE on its own.

分享给朋友:
您可能感兴趣的文章:
随机阅读: