我需要做以下事情:
Select ProID from Pros ps where ps.ProId = '102-C01-1299'
and ConfirmDate > DATEADD(DAY, (select tt.DaysDue from tblTaskTimeline tt where Task = 'TaskInfo') as days,ps.ProgStartDate)
注意如何为DATEADD函数,我需要动态获取第二个参数。 请注意,tt.DaysDue返回一个整数值。
我收到一条消息,说DATEADD需要3个参数。
答案 0 :(得分:1)
为什么不先创建参数?
declare @days int
set @days = (select tt.DaysDue from tblTaskTimeline tt where Task = 'TaskInfo')
Select ProID
from Pros ps
where ps.ProId = '102-C01-1299'
and ConfirmDate > DATEADD(DAY, @days, ps.ProgStartDate)
如果您不能使用参数,则以下内容应该有效:
Select ProID
from Pros ps
where ps.ProId = '102-C01-1299'
and ConfirmDate > DATEADD(DAY, (select tt.DaysDue from tblTaskTimeline tt where Task = 'TaskInfo'), ps.ProgStartDate)
答案 1 :(得分:0)
删除“as days”,它应该有效。