find rows within seconds of top of hour

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?
rcamarda [ Mi, 24 Oktober 2007 15:06 ] [ ID #1853272 ]

Re: find rows within seconds of top of hour

On Wed, 24 Oct 2007 06:06:53 -0700, rcamarda
<robert.a.camarda [at] gmail.com> wrote:

>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
Roy Harvey [ Mi, 24 Oktober 2007 17:15 ] [ ID #1853277 ]
Datenbanken » comp.databases.ms-sqlserver » find rows within seconds of top of hour

Vorheriges Thema: Need help Joining tables
Nächstes Thema: Reusing a generated column to avoid over processing