isle chow isle chow - 1 year ago 39
SQL Question

ADD 1 SEC to date in a column of table

using sql server 2008

i have date something like this,

2016-05-11 13:17:41.410


can i remove millisecond and add 1 sec

will look like this.

2016-05-11 13:17:42

Answer
declare @dt datetime = '2016-05-11 13:17:41.410'

select  @dt, dateadd(MILLISECOND, 1000 - datepart(MILLISECOND, @dt), @dt)