[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

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

Posted on 2011-03-12
3
Medium Priority
?
290 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 71

Accepted Solution

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

Assisted Solution

by:Sharath
Sharath earned 668 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 664 total points
ID: 35117631
Or, a third way,:

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

Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

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

An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
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…
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

650 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