PHP: filter: calculating age from birthday, BETWEEN xx AND xx
<p>After some research and little afford from myself I got this:</p>

<pre><code>     $query .= "SELECT * FROM users WHERE birthday &lt; SUBDATE(NOW(), INTERVAL BETWEEN $min AND $max YEAR)";
</code></pre>

<p>Although this doesn't work.</p>

<p>Users birthdays are stored in: 1991-01-01 in the birthday column. I have two fields in my form, that you can enter numbers in. example, 18 and 22.</p>

<p>then it will show all users that has the age between 18 and 22 ( 18,19,20,21,22).</p>

<p>^ And that is what im trying to filter out, with the query. But ive done something wrong, and maybe you cant do BETWEEN in INTERVAL, or what is wrong?</p>

<p>Im getting:</p>

<pre><code>You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'BETWEEN 17 AND 21 YEAR)' at line 1
</code></pre>
