在 T SQL 中将月份添加到日期
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7967459/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 13:04:46 来源:igfitidea点击:
Adding a month to a date in T SQL
提问by Joshua
How can I add one month to a date that I am checking under the where clause?
如何将一个月添加到我在 where 子句下检查的日期?
e.g.:
例如:
select *
from Reference
where reference_dt + 1 month
回答by Icarus
select * from Reference where reference_dt = DateAdd(month,1,another_date_reference)
回答by JonH
回答by K. Bob
DateAdd(m,1,reference_dt)
will add a month to the column value
将一个月添加到列值
回答by Purplegoldfish
DATEADD
is the way to go with this
DATEADD
是这样的方式
See the W3Schools tutorial: http://www.w3schools.com/sql/func_dateadd.asp
请参阅 W3Schools 教程:http: //www.w3schools.com/sql/func_dateadd.asp
回答by SliverNinja - MSFT
select * from Reference where reference_dt = DATEADD(mm, 1, reference_dt)