title: SQL Query between dates in VBA
body: <p>I've a problem making a sql query in VBA using excel and an access database. In mi VBA code I've two data variables with this content:</p>
  
  <p>DateMin = 31/07/2014 22:00:00</p>
  
  <p>DateMax = 01/08/2014 06:00:00</p>
  
  <p>And I have an access database with many data with a date field. I'm trying to extract from the database, data with dates between my two variables and I'm coding this:</p>
  
  <pre><code>sql = "SELECT Date FROM Table WHERE Date BETWEEN #" &amp; DateMin &amp; "# AND #" &amp; DateMax &amp; "#
  </code></pre>
  
  <p>But doesn't works. Results are incorrect, with dates that aren't between my two dates.</p>
  
  <p>However if I change the sentence and code this</p>
  
  <pre><code>sql = "SELECT Date FROM Table WHERE Date &gt; #" &amp; DateMin &amp; "#
  </code></pre>
  
  <p>It works! Gives data with higher dates than DateMin but I haven't DateMax to stop it. I think the problem is in the second part of my first code, because if I code</p>
  
  <pre><code>sql = "SELECT Date FROM Table WHERE Date &lt; #" &amp; DateMax &amp; "#
  </code></pre>
  
  <p>I have no data! Why doesn't give me data lower than DateMax? Because of that I think doesn't works the BETWEEN sentence.</p>
  
  <p>Sorry for my english, i'm trying to explain better I know. Thanks.</p>