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

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())
motioneyeAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
QlemoConnect With a Mentor Batchelor, Developer and EE Topic AdvisorCommented:
select 1, dateadd(hh, 12, convert(varchar(8), getdate(), 112))
0
 
SharathConnect With a Mentor Data EngineerCommented:
Another way.
select 1, DATEADD(hh,12,dateadd(dd,0,DATEDIFF(dd,0,getdate())))
0
 
8080_DiverConnect With a Mentor Commented:
Or, a third way,:

SET @ControlDateVariable = CONVERT(DateTime, CONVERT(VarChar(10), GETDATE(), 120), 120);
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.