How to add minutes to the time part of datetime

Anyname Donotcare picture Anyname Donotcare · Nov 17, 2015 · Viewed 66k times · Source

How to add minutes(INT) to the time part of datetime ?

For example :

If i have datetime variable like this :

  @shift_start_time =  2015-11-01 08:00:00.000

  @increase = 30

How to get the result :

2015-11-01 08:30:00.000

Answer

Lukasz Szozda picture Lukasz Szozda · Nov 17, 2015

Use DATEADD:

SELECT DATEADD(mi, @increase,   @shift_start_time);

db<>fiddle demo