开发者

Determine dates by number of days, "what date is 180 days from now

开发者 https://www.devze.com 2022-12-21 04:13 出处:网络
How to determine dat开发者_如何学编程es by number of days from now - \"What date is 180 days from now?\"DATEADD(d, 180, GetDate())

How to determine dat开发者_如何学编程es by number of days from now - "What date is 180 days from now?"


DATEADD(d, 180, GetDate())


SELECT DATEADD(day, 180, getdate())


getdate() + 180

for example:

select getdate() as Today, getdate() + 180 as About6MonthsLater


Since you just want the date, the time part should be stripped out after the calculation is done.

SELECT CONVERT (DATETIME, CONVERT (VARCHAR (20), DATEADD(d, 180, GetDate()), 101))


To find 180 days ahead and remove the time component in one easy go.

No relying on internal implementation (using +) or string handling to chop time.

SELECT DATEADD(day, DATEDIFF(day, 0, GETDATE()), 180)
0

精彩评论

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

关注公众号