|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Today @ 8:27 AM
Points: 206,
Visits: 508
|
|
I need to check if days are Sat, Sun and Mon and time between Sat 6am to Monday 6am. Can you please help?
I am trying something like this but I am stuck..
IF datepart(dw, getdate()) IN (1,7,2) AND (datepart(hour,getdate()) Between 6 AND ....)
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Today @ 9:13 AM
Points: 2,475,
Visits: 2,134
|
|
You may need to check the servers this runs on for what @@datefirst is otherwise a quick stab at this is:-
IF DATEPART(dw, GETDATE()) = 1-- any time on Sunday OR ( DATEPART(dw, GETDATE()) = 7 AND DATEPART(hour, GETDATE()) > 5 ) -- after 6 a.m. Saturday OR ( DATEPART(dw, GETDATE()) = 2 AND DATEPART(hour, GETDATE()) < 6 ) --before 6 a.m. Monday BEGIN PRINT 'Criteria correct' END But you need to check this as my server settings are different to yours
------------------------------- Posting Data Etiquette - Jeff Moden Smart way to ask a question
There are naive questions, tedious questions, ill-phrased questions, questions put after inadequate self-criticism. But every question is a cry to understand (the world). There is no such thing as a dumb question. ― Carl Sagan I would never join a club that would allow me as a member - Groucho Marx
|
|
|
|