Solved

getdate() in sql2005 to filter only records <=12:00:00.000

Posted on 2011-03-12
3
287 Views
Last Modified: 2012-06-27
I have one sql job which running at 12:15am midnight, following below is how I use to fiklter the record but die to we run this in sql job and most of the time I saw the job its not consistent when it get executed, (always delay for few seconds ), how do I construct a sql statemnet which will make sure it takes 12:00:00.000 every night ?


select 1,dateadd (mi,-15,getdate())
0
Comment
Question by:motioneye
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 70

Accepted Solution

by:
Qlemo earned 167 total points
ID: 35116615
select 1, dateadd(hh, 12, convert(varchar(8), getdate(), 112))
0
 
LVL 41

Assisted Solution

by:Sharath
Sharath earned 167 total points
ID: 35116748
Another way.
select 1, DATEADD(hh,12,dateadd(dd,0,DATEDIFF(dd,0,getdate())))
0
 
LVL 22

Assisted Solution

by:8080_Diver
8080_Diver earned 166 total points
ID: 35117631
Or, a third way,:

SET @ControlDateVariable = CONVERT(DateTime, CONVERT(VarChar(10), GETDATE(), 120), 120);
0

Featured Post

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

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

The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example, show how to shrink a transaction log file down to a reasonable size.

705 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