我需要做以下工作:
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个参数。
发布于 2012-08-03 01:05:21
去掉“as days”,它就可以工作了。
发布于 2012-08-03 01:04:48
为什么不先创建一个参数呢?
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)https://stackoverflow.com/questions/11782290
复制相似问题