SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Timestamp query
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

nemohm
Yak Posting Veteran

Canada
69 Posts

Posted - 04/30/2003 :  19:51:10  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

USA
1429 Posts

Posted - 04/30/2003 :  20:26:13  Show Profile  Reply with Quote
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

USA
503 Posts

Posted - 04/30/2003 :  23:33:24  Show Profile  Reply with Quote
You may need to use TSEQUAL() function.

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




Jung



Go to Top of Page

ValterBorges
Flowing Fount of Yak Knowledge

USA
1429 Posts

Posted - 05/01/2003 :  10:03:25  Show Profile  Reply with Quote
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 - 05/01/2003 :  10:41:22  Show Profile  Reply with Quote
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

Canada
69 Posts

Posted - 05/01/2003 :  11:15:04  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.12 seconds. Powered By: Snitz Forums 2000