SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


TIMESTAMP column


TIMESTAMP column

Author
Message
Nisha-475382
Nisha-475382
SSChasing Mays
SSChasing Mays (605 reputation)SSChasing Mays (605 reputation)SSChasing Mays (605 reputation)SSChasing Mays (605 reputation)SSChasing Mays (605 reputation)SSChasing Mays (605 reputation)SSChasing Mays (605 reputation)SSChasing Mays (605 reputation)

Group: General Forum Members
Points: 605 Visits: 364
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.
Stupeo
Stupeo
SSC Eights!
SSC Eights! (979 reputation)SSC Eights! (979 reputation)SSC Eights! (979 reputation)SSC Eights! (979 reputation)SSC Eights! (979 reputation)SSC Eights! (979 reputation)SSC Eights! (979 reputation)SSC Eights! (979 reputation)

Group: General Forum Members
Points: 979 Visits: 778
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.
Nisha-475382
Nisha-475382
SSChasing Mays
SSChasing Mays (605 reputation)SSChasing Mays (605 reputation)SSChasing Mays (605 reputation)SSChasing Mays (605 reputation)SSChasing Mays (605 reputation)SSChasing Mays (605 reputation)SSChasing Mays (605 reputation)SSChasing Mays (605 reputation)

Group: General Forum Members
Points: 605 Visits: 364
Right! Thank you so much!

Which means.. there's no way I can query this table since there's no Datetime field here!
Stupeo
Stupeo
SSC Eights!
SSC Eights! (979 reputation)SSC Eights! (979 reputation)SSC Eights! (979 reputation)SSC Eights! (979 reputation)SSC Eights! (979 reputation)SSC Eights! (979 reputation)SSC Eights! (979 reputation)SSC Eights! (979 reputation)

Group: General Forum Members
Points: 979 Visits: 778
Im afraid so.

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

Matt.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search