MS Access多重IF声明

时间:2018-02-26 20:37:12

标签: sql ms-access

我不确定为什么下面的代码在MS访问中给出了错误答案:

IIf([Due Date]-[Receipt Date] Between "15" And "100000","15 + days before due date",
IIf([Due Date]-[Receipt Date] Between "7" And "15","Less than 15 days before due date",
IIf([Due Date]-[Receipt Date] Between "0" And "7","Less than 7 days before due date",
IIf([Due Date]-[Receipt Date]  < 0,"After due date")))) AS [Timely Receipt]

请帮忙

1 个答案:

答案 0 :(得分:1)

我不确定直接减法会给你所需的反应。

你应该使用Datediff函数,即DateDiff(“d”,[截止日期],[收据日期])

将int与string进行比较 - 这是不需要的。如果在这种情况下删除数值周围的引号会更好。