dbTalk Databases Forums  

find rows within seconds of top of hour

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss find rows within seconds of top of hour in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
rcamarda
 
Posts: n/a

Default find rows within seconds of top of hour - 10-24-2007 , 08:06 AM






I have rows of data that have a datetime stamp. I need to find rows
that have a datetime stamp within 10 seconds of the top of each hour.
I started with datediff(s,getdate(),LeadDate) but I am stumped on how
to process for each hour.
I.E. records between 9:00:00 and 9:00:10 , 10:00:00 10:00:10, and so
forth for each hour.
Ideas?


Reply With Quote
  #2  
Old   
Roy Harvey (SQL Server MVP)
 
Posts: n/a

Default Re: find rows within seconds of top of hour - 10-24-2007 , 10:15 AM






On Wed, 24 Oct 2007 06:06:53 -0700, rcamarda
<robert.a.camarda (AT) gmail (DOT) com> wrote:

Quote:
I have rows of data that have a datetime stamp. I need to find rows
that have a datetime stamp within 10 seconds of the top of each hour.
I started with datediff(s,getdate(),LeadDate) but I am stumped on how
to process for each hour.
I.E. records between 9:00:00 and 9:00:10 , 10:00:00 10:00:10, and so
forth for each hour.
Ideas?
To select just the rows from those intervals:

SELECT *
FROM Whatever
WHERE DATEPART(minute,LeadDate) = 0
AND DATEPART(second,LeadDate) BETWEEN 0 AND 10

Roy Harvey
Beacon Falls, CT


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.