compare time in excel

送分小仙女□ 提交于 2020-01-14 10:22:44

问题


Excel experts, need your help to compute the check column, details below.

Column A             | Column B                | Column C        | Column D           | Check
12/07/2012  23:59:06 | 2012/07/12              | Thursday        | 23:59:06           |  ?
            -        | =TEXT(A2, "yyyy/mm/dd") | =TEXT(A3,"dddd")|=TEXT(A3,"HH:mm:ss")|

As you can see, I am extracting the date in column B, I am extracting the day in Column C, I have the time being extracted in Column D.

Column Check should be true if the below condition is met and false otherwise:

  1. If day is Saturday or Sunday then should be true
  2. If day is Monday to Friday and Time is > 6:30 pm and time < 07:30 am should be true.

This is the formula I have build which does not seem to work.

=IF(OR(C2="Saturday",C2="Sunday")+OR((D2>TIME(18,0,0)*AND(D2<TIME(7,0,0)))),TRUE,FALSE)

I get true for pretty much everything. Any help will be greatly appreciated.


回答1:


To write something like A OR B OR C, in excel 2010, you can simply write: OR(A, B, C).

In your case, it would be:

=OR(C2="Saturday",C2="Sunday",D2>TIME(18,0,0), D2<TIME(7,0,0))

I think you also need to use a proper time in column D instead of text:

=TIME(HOUR(A2),MINUTE(A2),SECOND(A2))


来源:https://stackoverflow.com/questions/11519719/compare-time-in-excel

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