Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

querying a timestamp field...

Status
Not open for further replies.

AWEinCA

Programmer
Oct 18, 2000
35
US
I get the following error when running my query:

“Server: Msg 260, Level 16, State 1, Line 1
Disallowed implicit conversion from data type datetime to data type timestamp, table 'trading.dbo.pricechg', column 'timestamp'. Use the CONVERT function to run this query.”

SELECT commodity_code, spot, timestamp
FROM pricechg
WHERE commodity_code = 'SILVER'
AND timestamp = (SELECT min(timestamp)
FROM pricechg
WHERE commodity_code = 'SILVER'
AND pricechg.timestamp = CONVERT(datetime,'7/16/2001'))

According to BOL I should be able to say: pricechg.timestamp = '7/16/2001'

What am I overlooking or doing wrong.

Thank you in advance for ANY help you can give.

Aaron
 

A timestamp column is not the same as a datetime column. You can't query it for a date. This is what BOL says about timestamp data type.

timestamp is a data type that exposes automatically generated binary numbers, which are guaranteed to be unique within a database. timestamp is used typically as a mechanism for version-stamping table rows. The storage size is 8 bytes.

IMO - timestamp is misnamed. Terry Broadbent
Please review faq183-874.

"The greatest obstacle to discovery is not ignorance -- it is the illusion of knowledge." - Daniel J Boorstin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top