Jim Beam Jim Beam - 1 year ago 100
SQL Question

SQL Server: Add seconds to a datetime field?

This should be a softball for you SQL guys. I know I can add to an int field with something like

UPDATE tblUser SET Total=(Total+2)
but what is the syntax for adding seconds to a datetime field?

I'm using SQLServer 2008

Answer Source
UPDATE tbluser SET DateField = DATEADD(ss,numOfSeconds,DateField)

Note the first parameter "ss". This shows that you are adding seconds to the date.

Check the docs for more info.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download