3 Replies Latest reply on Oct 14, 2016 9:57 AM by mhenry

    Help with an alert not working correctly


      I can't figure this one out. I've run it by a couple of people here at work and no one seems to be able to figure out why it's not working.


      The alert works fine during normal business hours but part that is supposed to keep it from running off hours and weekends doesn't do anything at all. THe alert keeps firing every 15 minutes no matter what I try. I've tried several iterations of code, using parenthesis in different places to try to make one block of code and nothing seems to work.


      Any ideas? Here's the alert:


      IF DATEPART(DW, GETDATE()) IN (2,3,4,5,6)


      (SELECT TOP 1 CreateDate FROM theTable

      WHERE ((DatePart(Hour,CreateDate) >= 5) AND (DatePart(Hour,CreateDate) <= 18)) AND CreateDate NOT IN ('01/01/2017', '11/24/2016', '11/25/2016', '12/26/2016') AND  CreateDate > DateADD(mi, -15, Current_TimeStamp))

      SELECT 0


      SELECT 1