SQL server dateadd

0

In sql server I have to create a new column in a preexisting table where I add another column that I have with seconds to the new one from a date:

alter table Emails add Date smalldatetime ALTER TABLE Emails ALTER COLUMN Date DATEADD('SECOND',Time,'11-05-2015 14:00:00')

But the error comes to me in:

  

SECOND, incorrect syntax expecting ID, NUMERIC, etc.

Can you help me! I've been with this for hours

    
asked by Florencia Diaz 17.05.2018 в 20:30
source

1 answer

0

You have several errors in your code:

  • Parameter 2 of the Dateadd expects a numeric value if you are adding seconds
  • The value on which you want to perform the calculation does not have quotes (second)
  • The alter of the column does not carry data type, since it is a calculated column; additionally it must be accompanied by the "As" clause before the definition of the formula.

    alter table EMails add New AS DATEADD column (SECOND, 14, DateParameter)

answered by 17.05.2018 в 21:41