Get Current Date

  • I was wondering if there was an sp or select statement that can get the current date in whatever form, preferably timestamp. This would need to work for both SQL Server 2000 and 2005. Thanks in advance

    -Kyle

  • Is this what you are looking for -

    SELECT getdate()

     

  • To elaborate further, if you are looking to get the current date in a specified format use:

    SELECT CONVERT(CHAR,GETDATE(),x) AS CurrentDate

    where x equals a style value. See the list of style value options in the following link. Hope this helps.

    http://msdn2.microsoft.com/en-us/library/ms187928.aspx

  • Thanks, I just followed the above advice and added a timestamp column to each one of my tables with the default value getDate()

    -Kyle

  • You may want to rethink the name as timestamp has a specific meaning in T-SQL land.

    "Is a data type that exposes automatically generated, unique binary numbers within a database. timestamp is generally used as a mechanism for version-stamping table rows. The storage size is 8 bytes. The timestamp data type is just an incrementing number and does not preserve a date or a time. To record a date or time, use a datetime data type."

    from BOL

    Of course there is also the ODBC/ OLE DB tumestamp...

    Oy.

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply