How to add time to DateTime in SQL

后端 未结 9 1990
一生所求
一生所求 2020-12-29 01:47

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,         


        
9条回答
  •  孤城傲影
    2020-12-29 02:27

    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.

提交回复
热议问题