Solved

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

Posted on 2011-03-12
3
286 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
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 extract information from SQL Server on Database, Connection and Server properties

732 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