Solved

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

Posted on 2011-03-12
3
284 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
3 Comments
 
LVL 69

Accepted Solution

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

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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
I have a large data set and a SSIS package. How can I load this file in multi threading?
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Viewers will learn how the fundamental information of how to create a table.

839 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