Date/Time Stamp

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Robert

    Date/Time Stamp

    When a record is written to a table (via a asp form), I'd like the time
    and date from the server to automatically populate a column in that
    table. From what I can tell, timestamp isn't working. I rather not
    have the time come from the client.

    Thanks for the help.

  • David Portas

    #2
    Re: Date/Time Stamp

    Add a column with a default of CURRENT_TIMESTA MP. This is nothing to do
    with TIMESTAMP, which is the SQL Server keyword for a row-versioning
    column, not for date and time.

    ALTER TABLE your_table ADD date_created DATETIME NOT NULL
    CONSTRAINT df_your_table_d ate_created DEFAULT CURRENT_TIMESTA MP

    --
    David Portas
    SQL Server MVP
    --

    Comment

    • Chandra

      #3
      Re: Date/Time Stamp


      alternatively, you can also use as

      ALTER TABLE your_table ADD date_created DATETIME NOT NULL
      CONSTRAINT df_your_table_d ate_created DEFAULT getdate()


      best Regards,
      Chandra

      Find the queries, documents, syntaxes, techniques in using MS SQL Server in an effecient way. I will try to collect maximum information and postit on the site.

      ---------------------------------------

      *** Sent via Developersdex http://www.developersdex.com ***

      Comment

      Working...