Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Timestamp query

Author  Topic 

nemohm
Yak Posting Veteran

69 Posts

Posted - 2003-04-30 : 19:51:10
I have a column with timestamp data type.

As usually I'm confused with dates!

What would look like e query against that table that will work?
(For queering in certain time period)

SELECT *
FROM event
WHERE logtimestamp > dateadd(hour, -1, getdate()

Thx,

Dobby

ValterBorges
Master Smack Fu Yak Hacker

1429 Posts

Posted - 2003-04-30 : 20:26:13
You can use

between timex and timey

or

>= timex and <= timey

be careful of comparing date with time of 0 against date with time.
also date calculations are only accurate to 3 milliseconds.


Go to Top of Page

jung1975
Aged Yak Warrior

503 Posts

Posted - 2003-04-30 : 23:33:24
You may need to use TSEQUAL() function.

[url]http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=19553[/url]




Jung



Go to Top of Page

ValterBorges
Master Smack Fu Yak Hacker

1429 Posts

Posted - 2003-05-01 : 10:03:25
oops!
TimeStamp Right

Are you sure you want to use a timestamp not a datetime?
Are you trying to track changes to each row and if so microsoft
suggests using rowversion instead because timestamp is likely to change in the future.

Edited by - ValterBorges on 05/01/2003 10:07:42
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2003-05-01 : 10:41:22
I've never used timestamp (DB2 Timestamp is a datetime and I remeber years ago be confused by this).

Does anyone use a timestamp? I mean isn't identity almost the same thing?

Just curious.



Brett

8-)
Go to Top of Page

nemohm
Yak Posting Veteran

69 Posts

Posted - 2003-05-01 : 11:15:04
I have table created with column logtimestamp - timestamp datatype by an aplication.
Rows are not changed, only new rows are added.

The access to table is via ODBC driver.

I need to transfer periodically this table to SS2K;
the chunks of data have to be hours or minutes.

SELECT *
FROM mt
WHERE lodtimestamp ??? --- must be one hour in the past

with datetime it's clear:

WHERE logtimestamp>DATEADD(hour, -1, GETDATE())

What (if there is any) is the way to achieve retrieval from timestamp datatype
for rows added in the last one hour?

Thx,

Dobby
Go to Top of Page
   

- Advertisement -