我有一个自定义列表,我试图限制数据输入的有效日期和时间。 我当前的列验证适用于星期一,星期三或星期五的星期几。它看起来像这样:
=CHOOSE(WEEKDAY([Requested date for approval]),FALSE,TRUE,FALSE,TRUE,FALSE,TRUE,FALSE)
我正在试图找出要添加的语法,它必须在那些日子的上午8点到中午12点之间。
非常感谢任何帮助。
答案 0 :(得分:0)
您可以使用AND语句来包含第二个条件
=AND(CHOOSE(WEEKDAY([Requested date for approval]),FALSE,TRUE,FALSE,TRUE,FALSE,TRUE,FALSE),
AND(
[Requested date for approval]-INT([Requested date for approval])*24 >= 8,
[Requested date for approval]-INT([Requested date for approval])*24 <= 24
)
)
我承认,我从未听说过CHOOSE功能,但时间计算是基于Microsoft的信息
转换时间 要将小时从标准时间格式转换为十进制数,请使用INT 功能
Column1 Formula Description (possible result) 10:35 AM =([Column1]-INT([Column1]))*24 Number of hours since 12:00 AM (10.583333) 12:15 PM =([Column1]-INT([Column1]))*24 Number of hours since 12:00 AM (12.25)
修改强>
要计算星期几,您可以使用TEXT函数返回星期几(即星期一)
=TEXT(WEEKDAY([ColumnName]), "dddd")
它不会很漂亮,但你可以使用一系列AND逻辑运算符
=AND(
TEXT(WEEKDAY([Requested date for approval]), "dddd") = "Monday",
AND(
TEXT(WEEKDAY([Requested date for approval]), "dddd") = "Wednesday",
AND(
TEXT(WEEKDAY([Requested date for approval]), "dddd") = "Friday",
AND(
[Requested date for approval]-INT([Requested date for approval])*24 >= 8,
[Requested date for approval]-INT([Requested date for approval])*24 <= 24
)
)
)
)
发布工作解决方案
=IF(
AND(
CHOOSE(
WEEKDAY([Requested date for approval]),FALSE,TRUE,FALSE,TRUE,FALSE,TRUE,FALSE
),
([Requested date for approval]-INT([Requested date for approval]))*24>=8,
([Requested date for approval]-INT([Requested date for approval]))*24<=12
),
TRUE
)