<p>I'm working on a site that uses a date slider to select members of the site by birthdate. I want to show the users by gender and between two "ages". For example: Male, between 40 and 50 years old. The selection on gender works perfect, but I can't seem to get the lowest age set. 
This is does work; with only the lower date set.     </p>

<pre><code>{% set dateRange = '&lt;= ' ~ lower_date %}

{% set queryParams = {
        geboortedatum : dateRange,
        order :'lastName'
    } 
%}  
</code></pre>

<p>But once I set the upper age I've got an error.</p>

<pre><code>{% set dateRange = '&lt;= ' ~ lower_date ~ ' AND =&gt; ' ~ upper_date %}

{% set queryParams = {
        geboortedatum : dateRange,
        order :'lastName'
    } 
%}  

{% set leden = craft.users(queryParams) %}
{% set leden = craft.users(queryParams) %}
</code></pre>

<p>This gets this error:</p>

<pre><code>Fatal error: Call to a member function getTimestamp() on a non-object in /chroot/home/deacteur/deacteursgilde.be/craft/app/helpers/DbHelper.php on line 597
</code></pre>

<p>Can anyone help me out here? I'm totally lost... Thanks a lot!!</p>

CC BY-SA 3.0
2016-05-12T17:03:30.960Z
I suspect it's going to come down to what the format of `lower_date` and `upper_date` are.  Can you update the question with those?
Brad Bell
CC BY-SA 3.0
2016-05-13T12:58:11.123Z
Also, isn't the operator wrong, shouldn't it be `>=`, not `=>`?
André Elvan
CC BY-SA 3.0
2016-06-13T13:38:57.297Z
Our code now:
`{% set dateRange = '>= ' ~ upper_date ~ ' AND <= ' ~ lower_date %}
{% set queryParams = { search: { query: geslacht_param_string, attribute: 'geslacht' }, geboortedatum : dateRange, order :'lastName' } %}
{% set leden = craft.users(queryParams) %} 

{# a dump of the queryParams prints this: array(3) { ["search"]=> array(2) { ["query"]=> string(5) "vrouw" ["attribute"]=> string(8) "geslacht" } ["geboortedatum"]=> string(31) ">= 1946-06-13 AND <= 1965-06-13" ["order"]=> string(8) "lastName" } #} `


Without success, it won't pick the members between the range...
Jan
<users><datetime>
Setting a date range on entry parameters
# Setting a date range on entry parameters

(Asked by: username_0 on 2016-05-12)

I'm working on a site that uses a date slider to select members of the site by birthdate. I want to show the users by gender and between two "ages". For example: Male, between 40 and 50 years old. The selection on gender works perfect, but I can't seem to get the lowest age set. 
This is does work; with only the lower date set.     
{% set dateRange = '<= ' ~ lower_date %}

{% set queryParams = {
        geboortedatum : dateRange,
        order :'lastName'
    } 
%}  

But once I set the upper age I've got an error.
{% set dateRange = '<= ' ~ lower_date ~ ' AND => ' ~ upper_date %}

{% set queryParams = {
        geboortedatum : dateRange,
        order :'lastName'
    } 
%}  

{% set leden = craft.users(queryParams) %}
{% set leden = craft.users(queryParams) %}

This gets this error:
Fatal error: Call to a member function getTimestamp() on a non-object in /chroot/home/deacteur/deacteursgilde.be/craft/app/helpers/DbHelper.php on line 597

Can anyone help me out here? I'm totally lost... Thanks a lot!!

**Tags:** users, datetime
> **Comments:**
> **username_1**: I suspect it's going to come down to what the format of `lower_date` and `upper_date` are.  Can you update the question with those?  
> **username_2**: Also, isn't the operator wrong, shouldn't it be `>=`, not `=>`?  
> **username_0**: Our code now: `{% set dateRange = '>= ' ~ upper_date ~ ' AND <= ' ~ lower_date %} {% set queryParams = { search: { query: geslacht_param_string, attribute: 'geslacht' }, geboortedatum : dateRange, order :'lastName' } %} {% set leden = craft.users(queryParams) %}   {# a dump of the queryParams prints this: array(3) { ["search"]=> array(2) { ["query"]=> string(5) "vrouw" ["attribute"]=> string(8) "geslacht" } ["geboortedatum"]=> string(31) ">= 1946-06-13 AND <= 1965-06-13" ["order"]=> string(8) "lastName" } #} `   Without success, it won't pick the members between the range...  

---

## 0 answers

