title: How to check current date between two given dates in MySQL?
body: <p>I need help with a MySQL query to check current date between two given dates and using if condition. Below is my query statement:</p>
  
  <pre><code>$selMesQuery="select Subject, Message, PlainMessage, ARActiveTime, ARTimeZone, ARStartTime, AREndTime, ARID, UserId, DispLogo, ContentType from mytable";
  </code></pre>
  
  <p><em>ARActiveTime will be <strong>0 or 1</strong>.</em></p>
  
  <p><em>ARStartTime, AREndTime will be in <strong>datetime format</strong> ex:2015-03-25 22:15:00</em></p>
  
  <ol>
  <li>If <strong><em>ARActiveTime is '0'</em></strong>, I don't need values of <strong><em>ARTimeZone, ARStartTime, AREndTime</em></strong> but I need other values.</li>
  <li>I need the values of <strong><em>ARTimeZone, ARStartTime, AREndTime</em></strong> along with other values only if <strong><em>ARActiveTime is '1' and system time should be in between ARStartTime and AREndTime.</em></strong> </li>
  </ol>
  
  <p>How do I do this with mysql query statements??</p>
  
  <p>I can do this by executing the given query, checking whether ARActiveTime is 0 or 1 and then get current date, checking from and to dates with php code. But can it be done only with mysql statements only?</p>
  
  <p>May be can it be done using IF condition in query? I'm not sure.</p>
  
  <p>Any help would be greatly appreciated.</p>
  
  <pre><code>sample data of mysql table:
  _________________________________________________________________________________
  table header is as per the mysql query given 
  __________________________________________________________________________________
  sub1 | msg1 | pmsg1 | 0 | 0 |0000-00-00 00:00:00|0000-00-00 00:00:00| 1 | 1 | 0 | 2
  _________________________________________________________________________________
  sub2 | msg2 | pmsg2 | 1 | 3 |2015-03-12 10:00:00|2015-03-25 22:00:00| 2 | 1 | 1 | 1
  _________________________________________________________________________________
  sub3 | msg3 | pmsg3 | 1 | 2 |2015-03-10 20:00:00|2015-03-15 20:00:00| 3 | 2 | 1 | 2
  _________________________________________________________________________________
  sub4 | msg4 | pmsg4 | 0 | 0 |0000-00-00 00:00:00|0000-00-00 00:00:00| 4 | 3 | 0 | 3
  _________________________________________________________________________________
  
  
  desired result:
  _________________________________________________________________________________
  sub1 | msg1 | pmsg1 |                                                 1 | 1 | 0 | 2
  _________________________________________________________________________________
  sub2 | msg2 | pmsg2 | 1 | 3 |2015-03-12 10:00:00|2015-03-25 22:00:00| 2 | 1 | 1 | 1
  _________________________________________________________________________________
  sub3 | msg3 | pmsg3 | 1 | 2 |2015-03-10 20:00:00|2015-03-15 20:00:00| 3 | 2 | 1 | 2
  _________________________________________________________________________________
  sub4 | msg4 | pmsg4 |                                                 4 | 3 | 0 | 3
  _________________________________________________________________________________
  </code></pre>