开发者

add a year and subtract a day, using datepart in my query

Where (DYYYY = (year( getdate() +1)))DatePart(month, GETDATE())) + '/' + DatePart(day, GetDate())) -1 + '/' + DatePart(year, GetDate())) +1)

I am having 开发者_开发百科trouble running a query where i can use yesterdays date, but next year for projections.


Will this give you what you're looking for?

DATEADD(yy, 1, DATEADD(dd, -1, getdate()))

If you want to exclude the time component, then you can use a variation like this

DATEADD(yy, 1, DATEADD(dd, datediff(dd, 0, getdate()), -1))
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜