TIMESTAMP column

  • I have a Customers table with a TIMESTAMP column Date_Registered. I only see 'Binary Data' as values in this column when I open this table.

    I need to query this table to return all Applications that were registered between 2007 and 2008.

    How do I do this?

    SELECT * FROM dbo.Customers

    WHERE Date_Received BETWEEN '1/1/2007' AND '12/31/2008'

    Gives me the following error:

    Implicit conversion from data type varchar to timestamp is not allowed. Use the CONVERT function to run this query.

    SELECT * FROM dbo.Customers

    WHERE CONVERT(NVARCHAR,Date_Received) BETWEEN '1/1/2007' AND '12/31/2008'

    Gives me the following error:

    Explicit conversion from data type timestamp to nvarchar is not allowed.

    SELECT * FROM dbo.Customers

    WHERE Date_Received BETWEEN CONVERT(TIMESTAMP,'1/1/2007') AND CONVERT(TIMESTAMP,'12/31/208')

    as well as

    SELECT * FROM dbo.Customers

    WHERE CONVERT(DATETIME,Date_Received) BETWEEN '1/1/2007' AND '12/31/2008'

    Returns absolutely no records.

  • The timestamp data type doesnt preserve time or date data. It is for versioning a row and is automatically populated when an insert or update takes place.

    Take a look at this MSDN page for more info: http://msdn.microsoft.com/en-us/library/ms182776.aspx

    Thanks,

    Matt.

  • Right! Thank you so much!

    Which means.. there's no way I can query this table since there's no Datetime field here!

  • Im afraid so.

    And i think the TIMESTAMP data type name is a bit misleading.

    Matt.

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

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