E
E
Eugene2017-04-14 22:17:18
css
Eugene, 2017-04-14 22:17:18

How to make a request with a time condition?

In general, the situation, I have a table:

CREATE TABLE IF NOT EXISTS `notification` (
  `id` int(7) NOT NULL AUTO_INCREMENT,
  `to_id` int(15) NOT NULL,
  `set_time_in` time NOT NULL DEFAULT '00:00:00',
  `set_time_out` time NOT NULL DEFAULT '00:00:00',
  `stop` time NOT NULL DEFAULT '00:00:00',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

The script works almost always. The user sets that notifications are sent to him only from 10:00 to 18:00, and the other - from 15:00 to 03:00.
What request to make to the database with time H: i (current), who allowed to send a notification at this time?
For example:
1) at 16:00 a notification arrives to both.
2) at 02:00 the notification arrives only to the second one.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
TCloud, 2018-04-13
@Odyvanchik

<div class="container">
  
<div class="black-block">
  
  <div class="white-block">
    
  </div>

</div>
</div>

.black-block{
  background-color: rgba(0,0,0,.95);
  width: 180px;
  height: 300px;
  position: relative; /* ВАЖНО */
  display: block; 
}

.white-block{
  background-color: rgba(255, 255, 255, .95);
  width: 180px;
  height: 180px;
  position: absolute;
bottom: 0;
  right: 0;
  border-top-left-radius: 15px;
border-top-right-radius: 15px;
}

R
Rsa97, 2017-04-14
@xmax

WHERE IF (`set_time_in` > `set_time_out`, 
          `set_time_in` <= CURTIME() OR `set_time_out` >= CURTIME(),
          `set_time_in` <= CURTIME() AND `set_time_out` >= CURTIME())

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question