Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

query for the last 15 minutes

Status
Not open for further replies.

msg83

IS-IT--Management
Sep 18, 2002
20
0
0
US
I would like to be able to do is query a specific IP record and see if its 'DateTime' fell within the last 15 minutes. Seems easy enough, but we're having a tough time figuring out SQL syntax for making a decision on minutes of a timestamp in the 'DateTime' column.

I am trying create a query that returns data for the last 15 minutes. This is what i have for the syntax, but its returning no data. Can someone show me what i'm doing wrong.



SELECT COUNT(*) FROM VCSResults WHERE VCSIP = '123#123#3#149' AND datetime>dateadd(n,-15,getdate())
 
If you run this together

select getdate()
select dateadd(n,-15,getdate())

it returns
the time for now and the -15 minutes
---------------------------
2006-12-13 01:21:36.923

(1 row(s) affected)


---------------------------
2006-12-13 01:06:36.923

(1 row(s) affected)

So that part is working.

Would this helP?


AND datetime between dateadd(n,-15,getdate()) and getdate()
 
Are you sure you store IP adress with [#] sign?
VCSIP = '123#123#3#149'
and not like this:
VCSIP = '123.123.3.149'


Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
MVP VFP
 
Thanks everyone. This is exactly what i was looking for. Concerning the # this is what is stored when i capture the ivr utterance. I bascially am working with an ivr that speaks back the ip address then i store that ip in the database.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top