iif((([START DATE]<(cdate(format(year() & [WinterStartMonth] & [WinterStartDay],"####/##/##")))) AND ([START DATE]>(cdate(format(year() & [SummerStartMonth] & [SummerStartDay], "####/##/##"))))), (DateAdd("d", [WinterInspectionDropDead], [START DATE])), (DateAdd("d", [SummerInspectionDropDead], [START DATE]))) AS dropDead
有人能发现这个问题吗?我想我已经用括号进入了OTT,但我似乎无法摆脱错误。
答案 0 :(得分:0)
您通常可以使用VBA轻松发现错误,因此:
IIf([START DATE] < DateSerial(Year(Date),[WinterStartMonth],[WinterStartDay]) _
And [START DATE] > DateSerial(Year(Date),[SummerStartMonth],[SummerStartDay]), _
DateAdd("d", [WinterInspectionDropDead], [START DATE]), DateAdd("d", _
[SummerInspectionDropDead], [START DATE]))
只需删除SQL的换行符:
IIf([START DATE] < DateSerial(Year(Date), [WinterStartMonth], [WinterStartDay])
And [START DATE] > DateSerial(Year(Date),[SummerStartMonth], [SummerStartDay]),
DateAdd("d", [WinterInspectionDropDead], [START DATE]),
DateAdd("d", [SummerInspectionDropDead], [START DATE])) As Result
或者可能更好:
IIf([START DATE] < DateSerial(Year(Date), [WinterStartMonth], [WinterStartDay])
And [START DATE] > DateSerial(Year(Date),[SummerStartMonth],[SummerStartDay]),
[START DATE] + [WinterInspectionDropDead],
[START DATE] + [SummerInspectionDropDead])
As Result