Solved

tsql how to check if date between 9:00pm-10:00pm from Saturday to Wednesday

Posted on 2012-12-24
1
395 Views
Last Modified: 2013-01-09
i have @messsage i want if it's inserted from date 9:00pm to 10:00pm from saturday to wednesday to
do insert into () value ()
0
Comment
Question by:afifosh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 69

Accepted Solution

by:
Qlemo earned 500 total points
ID: 38719972
Can you clarify? You want to check if now is between 9pm and 10pm, every day from Sat to Wed, and if so perform an insert?
if (datepart(hh, getdate()) = 21 and datepart(dw, getdate() not between 5 and 6)
    insert into tbl (a, b) select 1, 2

Open in new window

(code is assuming you have US setting of Sunday as start of week).
0

Featured Post

Free Webinar: AWS Backup & DR

Join our upcoming webinar with experts from AWS, CloudBerry Lab, and the Town of Edgartown IT to discuss best practices for simplifying online backup management and cutting costs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question