March 21, 2013 at 7:19 pm
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 ....)
March 22, 2013 at 1:54 am
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 [/url]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
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy