use IF() with TIMEVALUE() in excel

本秂侑毒 提交于 2019-12-08 14:35:29

Try to evaluate the formula step by step to see, if this is what you want.

Working formula:
=IF(TIMEVALUE("14:30") - NOW() < TIMEVALUE("00:00");"Past";"Future")

Evaluated arguments, using [F9 key]:
=IF(0,604166666666667 - 42719,6943635416 < 0;"Past";"Future")

You will always get the "Past" as returned value.

Explanation of date and time in Excel

The TIME in Excel is a proportion of a day. "00:00" = 0.00 and "24:00" = 1.00. Other values of TIME are DECIMALS between 0 and 1.

The DATE is a number of days since the first day. "1900-01-01" = 1 and "2000-01-01" = 36526. It is always an INTEGER.

Combining DATA and TIME (like in NOW() function) gives you an INTEGER + DECIMAL. When I evaluated the NOW() it returned 42719,6943635416

The TIMEVALUE function expects a STRING/TEXT that is considered a TIME and converts that STRING/TEXT to DECIMAL between <0; 1>.

Links

MS - How to use dates and times in Excel
Trump-Excel:Identify Errors Using Excel Formula Debugging (2 Methods)

Convert the Now to string first, using Text function, then it will work as expected.

TEXT(NOW(),"HH:MM:SS")

Final formula:

=IF((TIMEVALUE("11:30") - TIMEVALUE(TEXT(NOW(),"HH:MM:SS"))) < TIMEVALUE("00:00"),"Past","Future")

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