问题
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:
- If day is Saturday or Sunday then should be true
- 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