Sql 如何选择第一列日期和第二列时间作为日期时间
我想选择第一个字段的日期部分和时间部分减去第二个字段的3小时作为datetime。我已经尝试了以下方法,它只需要几个小时的时间场,因为我只需要几个小时。如何通过将完成日期和时间减去3小时来实现。如果有简单的方法,请帮助我Sql 如何选择第一列日期和第二列时间作为日期时间,sql,date,time,Sql,Date,Time,我想选择第一个字段的日期部分和时间部分减去第二个字段的3小时作为datetime。我已经尝试了以下方法,它只需要几个小时的时间场,因为我只需要几个小时。如何通过将完成日期和时间减去3小时来实现。如果有简单的方法,请帮助我 declare @ReminderDate DATETIME='2013-12-22 01:01:01.000' declare @ReminderTime DATETIME='2014-09-10 14:09:00.000' select cast(cast(cast(
declare @ReminderDate DATETIME='2013-12-22 01:01:01.000'
declare @ReminderTime DATETIME='2014-09-10 14:09:00.000'
select cast(cast(cast( @ContactMadeReminderDate as DATE) as nvarchar(15))+' ' + cast(LEFT(CONVERT(TIME(0), @ContactMadeReminderTime), 2)-3 as nvarchar(15) ) +':00' as datetime)
请尝试此查询
SELECT CAST(CAST(@ReminderDate AS Date) AS DateTime) + CAST(DATEADD(HOUR,-3,@ReminderTime) AS TIME)