| Author |
Topic |
|
kingpoop
Starting Member
6 Posts |
Posted - 2010-11-08 : 00:08:39
|
| Hello:I am trying to run some code within an IF statement and I only want to execute the code block at midnightwhat am i doing wrong?IF GETDATE() BETWEEN '23:59' AND '00:30'BEGIN...ENDThanks for your help. |
|
|
pk_bohra
Master Smack Fu Yak Hacker
1182 Posts |
Posted - 2010-11-08 : 01:05:38
|
| what version of SQL server you are using ? |
 |
|
|
kingpoop
Starting Member
6 Posts |
Posted - 2010-11-08 : 01:06:47
|
| SQL Server 2008 |
 |
|
|
pk_bohra
Master Smack Fu Yak Hacker
1182 Posts |
Posted - 2010-11-08 : 02:49:06
|
| Why don't you schdule a job to run at midnight.You don't have to worry about checking the time and calling the code based on time format. |
 |
|
|
kingpoop
Starting Member
6 Posts |
Posted - 2010-11-08 : 02:51:28
|
| this sproc is called by a single job and the job calls several sprocs. this particular sproc can only run at midnight.i cannot use another job for this task. |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-11-08 : 02:57:32
|
You have opened three threads for the same problem.http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=152661http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=152660Please don't do that because it is difficult for us to help in this case.And please correct your CAPS LOCK because writing in UpperCase is like shouting us! No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
pk_bohra
Master Smack Fu Yak Hacker
1182 Posts |
Posted - 2010-11-08 : 03:03:25
|
| Something to start with:Getdate betweendateadd(mi,-1,dateadd(d,1,dateadd(d,datediff(d,0,getdate()),0)))Betweendateadd(mi,30,dateadd(d,1,dateadd(d,datediff(d,0,getdate()),0))) |
 |
|
|
TimSman
Posting Yak Master
127 Posts |
Posted - 2010-11-08 : 12:40:03
|
| why is this sproc called by another one if it should only run once a day? |
 |
|
|
kingpoop
Starting Member
6 Posts |
Posted - 2010-11-09 : 13:02:49
|
quote: Originally posted by TimSman why is this sproc called by another one if it should only run once a day?
It's not called by another sproc. There is a job that calls six sprocs and this one is the 6th and final sproc. When this sproc is called i need to check if the time is midnight...if yes, then perform some tasks. |
 |
|
|
|