?
Solved

Determine seconds

Posted on 2011-10-17
7
Medium Priority
?
169 Views
Last Modified: 2012-05-12
How do I do a select on whether a record was created (createdDate) in last 30 seconds?

If exists where phoneNumber = @phoneNumber and status = 'Logged' and createdDate (in last 30 seconds)
0
Comment
Question by:lrbrister
7 Comments
 
LVL 32

Expert Comment

by:Ephraim Wangoya
ID: 36979819

where datediff('SECOND', createdDate, GETDATE()) > 30
0
 
LVL 32

Expert Comment

by:Ephraim Wangoya
ID: 36979831
remove the quotations

where datediff(SECOND, createdDate, GETDATE()) > 30
0
 
LVL 18

Expert Comment

by:Cluskitt
ID: 36979835
It's actually < 30
0
Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

 
LVL 32

Accepted Solution

by:
Ephraim Wangoya earned 2000 total points
ID: 36979837
Sorry, your are looking for within 30 seconds so it needs to be less than

where datediff(SECOND, createdDate, GETDATE()) < 30
0
 
LVL 23

Expert Comment

by:Rajkumar Gs
ID: 36979838

select * from yourtable where  datediff(second, yourdatetimecolumn, getdate()) <= 30
0
 

Author Closing Comment

by:lrbrister
ID: 36979959
Thanks
0
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 36979981
If you want to make use of any index on the 'createdDate' column, you must use this

select * from yourtable where yourdatetimecolumn >=  dateadd(second,-30 , getdate())
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Viewers will learn how the fundamental information of how to create a table.
Suggested Courses

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question