如何在 SQL 中为 CURRENT_TIMESTAMP 添加月份? [英] How do I add months to a CURRENT_TIMESTAMP in SQL?

查看:47
本文介绍了如何在 SQL 中为 CURRENT_TIMESTAMP 添加月份?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何向 SQL Server 中的 CURRENT_TIMESTAMP 添加月份?

How can I add months to the CURRENT_TIMESTAMP in SQL Server?

解决方案可能在于 DATEADD() 但这仅适用于日期,而不适用于日期时间.

The solution probably lies in DATEADD() but this works with a date only, not a datetime.

谢谢.

推荐答案

这很好用

SELECT DATEADD(month,1,CURRENT_TIMESTAMP)

来自 DATEADD (Transact-SQL)

日期

是一个表达式,可以解析为时间、日期、smalldatetime、datetime、datetime2 或日期时间偏移值.

Is an expression that can be resolved to a time, date, smalldatetime, datetime, datetime2, or datetimeoffset value.

这篇关于如何在 SQL 中为 CURRENT_TIMESTAMP 添加月份?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆