[英]subtract year using Select Dateadd() sqlserver
I have 2 textboxes: expiredfrom and expiredto. 我有2个文本框:expiredfrom和expiredto。 These textboxes allow user to find people that are using license and will expired within a year after payment in a range from 'expired from' to 'expired to'.
这些文本框允许用户查找使用许可证的人员,这些人员将在付款后的一年内过期,范围从“过期时间”到“过期时间”。 In my database, it only show the date of purchase, so Im trying to use SELECT DATEADD() function to subtract the user input by 1 year so the expired date will same as purchase date.
在我的数据库中,它仅显示购买日期,因此我试图使用SELECT DATEADD()函数将用户输入减去1年,因此到期日期将与购买日期相同。 However, when I try to implement, it shows that there is syntax error in it.
但是,当我尝试实现时,它表明其中存在语法错误。 What is the problem?
问题是什么? thanks
谢谢
(@ExpiredFrom IS NULL OR @ExpiredFrom = '' OR
@ExpiredTo IS NULL OR @ExpiredTo = '' OR
db.[dbo].Subscription.PurchaseDate BETWEEN SELECT DATEADD(yyyy,-1, @ExpiredFrom)
AND SELECT DATEADD(yyyy,-1,@ExpiredTo))
I would suggest you remove SELECT
there. 我建议您在那里删除
SELECT
。 Simply BETWEEN DATEADD(yyyy,-1, @ExpiredFrom) AND DATEADD(yyyy,-1,@ExpiredTo))
只需在
BETWEEN DATEADD(yyyy,-1, @ExpiredFrom) AND DATEADD(yyyy,-1,@ExpiredTo))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.