将日期添加到日期并在SQL SERVER 2012的表中插入添加日期(Add days to a date and insert added date in table for SQL SERVER 2012)
@Rdatetime ='2017-04-18 11:49:38.633'
@日期添加= 2
@Output ='2017-04-20 11:49:38.633'
大家好,这是我的问题,我得到Rdatetime和日期被添加到另一个表中。 我有哟添加日期并以日期时间格式保存
提前致谢
@Rdatetime ='2017-04-18 11:49:38.633'
@Date to add = 2
@Output = '2017-04-20 11:49:38.633'
Hi all, This is my Problem , i am getting Rdatetime and date to be added in another table . i have yo add the date and save it in datetime format
thanks in advance
最满意答案
使用DATEADD内置函数:
DECLARE @Rdatetime DATETIME ='2017-04-18 11:49:38.633' DECLARE @Date INT = 2 DECLARE @Output DATETIME = DATEADD(DAY,@Date,@Rdatetime) SELECT @OutputUse DATEADD built in function :
DECLARE @Rdatetime DATETIME ='2017-04-18 11:49:38.633' DECLARE @Date INT = 2 DECLARE @Output DATETIME = DATEADD(DAY,@Date,@Rdatetime) SELECT @Output更多推荐
发布评论