September 5, 2007 at 12:00 pm
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
September 5, 2007 at 12:05 pm
Is this what you are looking for -
SELECT getdate()
September 6, 2007 at 9:47 am
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.
September 6, 2007 at 9:49 am
Thanks, I just followed the above advice and added a timestamp column to each one of my tables with the default value getDate()
-Kyle
September 6, 2007 at 2:01 pm
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