0
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,但我似乎无法摆脱错误。

4

1 回答 1

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
于 2013-01-31T15:11:47.373 回答