Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jan 2003
    Posts
    111
    Thanks
    2
    Thanked 0 Times in 0 Posts

    SQL Server timestamp

    How do you set up a SQL Server database column to insert a timestamp automatically?

    I set the Data Type to "timestamp" but it inserts this in every row: <Binary>

    If I set to "datetime" I cannot figure out how to have it insert the stamp - it just gives NULL.

    I know how to pass the time to through an insert but would rather the database field handle it by default.
    Last edited by zenweezil; 09-15-2005 at 10:50 PM.

  • #2
    Regular Coder
    Join Date
    Jun 2005
    Posts
    804
    Thanks
    0
    Thanked 0 Times in 0 Posts
    SQL Server's timestamp is not the same as standard SQL's timestamp; it doesn't actually contain a date and time value. You'll need to create a datetime column with a default of GETDATE() or CURRENT_TIMESTAMP. Note that that will only store the creation time; if you need to store modification times also, I think you'll have to do it in your INSERT. I'm not positive on that last point, though.

  • #3
    Regular Coder
    Join Date
    Jan 2003
    Posts
    111
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Thumbs up Thanks!!

    Thanks - GETDATE() worked like a CHARM

  • #4
    Regular Coder
    Join Date
    Jan 2003
    Posts
    111
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Arrow How do you format getdate

    What do I do to get the date to drop the hours, minutes and seconds so it looks like this: dd/mm/yyyy only


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •