write query so that it should NOT include any records within the last hour

how to write query so that it should NOT include any records within the last hour
 

 job_date
9/3/2013 11:45:55 PM
9/3/2013 11:47:18 PM
9/3/2013 11:49:34 PM
9/3/2013 11:51:01 PM
9/3/2013 11:54:44 PM
9/2/2013  10:11:11 AM

Open in new window

LVL 20
chaitu chaituAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

HuaMin ChenProblem resolverCommented:
Try
 ... job_date between dateadd(hh,-1,GETDATE()) and getdate()

Open in new window

0
PortletPaulfreelancerCommented:
--NOT include any records within the last hour,
assuming there are no datetime values into the future than you do want

where job_date < dateadd(hour,-1,GETDATE())
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CEHJCommented:
Do you want it in Java?
0
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

chaitu chaituAuthor Commented:
no i want in sql server.i want to exclude the records which are inserted in the last 1 hr.
0
sameer2010Commented:
You can use this
select * from your_table where 
job_date < dateadd(hh,-1,getdate())

Open in new window

0
sameer2010Commented:
Oops...page refresh issue. PorterPaul has already posted this.
0
CEHJCommented:

no i want in sql server.i want to exclude the records which are inserted in the last 1 hr.
In that case, please don't post in Java TA - it just wastes people's time
0
chaitu chaituAuthor Commented:
will it exclude records for last 1 hr  based on Timestamp ?
0
PortletPaulfreelancerCommented:
A SQL Server timestamp field has nothing to do with dates or times (despite the name).

What type of field is [job_date]?

----
assuming job_date isn't a timestamp field:

if you want higher level of sub-second precision than GETDATE() you could use SYSDATETIME but I doubt that is necessary, i.e.

where job_date < dateadd(hour,-1,SYSDATETIME() )

see notes at: GETDATE (Transact-SQL)

you could also compare these results:
SELECT dateadd(hour,-1,GETDATE()), dateadd(hour,-1,SYSDATETIME())
0
PortletPaulfreelancerCommented:
nb: rowversion at SQL 2012 documents online:
"timestamp is the synonym for the rowversion data type"
"The timestamp syntax is deprecated. This feature will be removed in a future version of Microsoft SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature."

In SQL Server "timestamp" was rather an unfortunate choice of term for something that provides a unique reference to a row, but which cannot be used to identify either date or time.
0
HuaMin ChenProblem resolverCommented:
Try

 ... job_date < dateadd(hh,-1,GETDATE())

Open in new window

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.