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

  • Equivalent of Oracle's RowID in SQL Server
  • group date range with specific range
  • how to show column value only one time if it is repeated and blank until different value comes in sql
  • How to control what users can decrypt SQL Server Symmetric Key Encryption
  • Datatype for System.Version in sql server
  • Pivot Data Using a SQL Select Query
  • 2 Solutions collect form web for “SQL Server: Add seconds to a datetime field?”

    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.

    You should look into DATEADD.

    DATEADD (datepart , number , date)

    or the full update syntax

    UPDATE tbl SET YourDateField = DATEADD (ss, 2, YourDateField)

    MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.