I\'m trying to add custom time to datetime in SQL Server 2008 R2.
Following is what I\'ve tried.
SELECT DATEADD(hh, 03, DATEADD(mi,
Start Day Time : SELECT DATEADD(day, DATEDIFF(day, 0, GETDATE()), '00:00:00')
End Day Time : SELECT DATEADD(day, DATEDIFF(day, 0, GETDATE()), '23:59:59')
You can do:
SELECT GETDATE()+'03:30:00'
Try this:
SELECT DATEDIFF(dd, 0,GETDATE()) + CONVERT(DATETIME,'03:30:00.000')
For me, this code looks more explicit:
CAST(@SomeDate AS datetime) + CAST(@SomeTime AS datetime)
Try this
SELECT DATEADD(day, DATEDIFF(day, 0, GETDATE()), '03:30:00')
Try this
SELECT DATEADD(MINUTE,HOW_MANY_MINUTES,TO_WHICH_TIME)
Here MINUTE is constant which indicates er are going to add/subtract minutes from TO_WHICH_TIME specifier. HOW_MANY_MINUTES is the interval by which we need to add minutes, if it is specified negative, time will be subtracted, else would be added to the TO_WHICH_TIME specifier and TO_WHICH_TIME is the original time to which you are adding MINUTE.
Hope this helps.