如何使用datepart从当前月份添加一个月 [英] how to add one month from the current month using datepart
问题描述
如何使用datepart从当前月份添加一个月
以上内容我写了如下查询
选择datepart(month,getdate())作为月份
当我执行输出时如下
月
7
它工作正常,假设当月是12月当我执行上面的查询
输出如下,
select datepart(month,getdate( ))作为月份
月
13
假设当月是十二月,并从当月添加一个月我希望输出如下,
如果当前月份是,我想要如下12月
月
1.
为什么我可以写sql查询。
Rgds,
Narasiman P.
选择 datepart(月,dateadd(月, 1 ,' 20131201')) as 月
选择datepart(month,dateadd(month,1,getdate()))为[month]
how to add one month from the current month using datepart
for the above thing i written the query as follows
select datepart(month,getdate()) as Month
when i execute the output as follows
Month
7
it is working correctly, suppose current month is December when i execute the above query
the output as follows,
select datepart(month,getdate()) as Month
Month
13
suppose current month is december,and add one month from the current month i want the output as follows,
Output i want as follows if current month is december
Month
1.
for that how can i write the sql query.
Rgds,
Narasiman P.
select datepart(month,dateadd(month,1,'20131201') ) as Month
select datepart(month, dateadd(month, 1, getdate())) as [month]
这篇关于如何使用datepart从当前月份添加一个月的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!