Hi all,

I’ve been searching for how to use daterange parameter but can’t find it.
What operator can i use? Anyone can help me?
Thanks!

Abed

just add date range param to your query(Ctrl+p) or press the btn add param
then select the type date range
this will add a text to your query
{{ date range.start }} {{ date range.end }}

Hi BigFF,

Thank you for your assist! I don’t know why i failed to notice that parameter button there.

Hi,
Can you give an example how to use date range in sql and mongo query.
what I am doing is like.
select * from table_name
where {{ column_name.start }} {{ column_name.end }}
Can you please tell me what I am doing wrong.

Hi Avinash,

You can try:
select * from table_name
where date_column between ‘{{ parameter_name.start }}’ and ‘{{ parameter_name.end }}’

Hope it helps!

Abed

It works, thanks for the help.
And one more thing can you please help me with mongo syntax for date range.

It helps to think about date range parameters as two individual values that share a control box. {{ parameter_name.start }} is one and {{ paramter_name.end }} is another. You insert these in your query (whether SQL or no SQL) in exactly the same places that you would otherwise include dates.

A simple Mongo example would be:

{
    "collection": "date_test",
    "query": {
        "lastModified": {
            "$gte": {
                "$humanTime": "{{ parameter_name.start }}"
            },
            "$lte": {
                "$humanTime": "{{ parameter_name.end }}"
            }
        }
    }
}

How can I use Pass allowDiskUse:true in redash for mongo query

I saw that you created a separate forum topic for this question. Thanks for that!

Hi Jesse, how to find data by querying date range parameters in MongoDB? I get the empty result. Could you please tell me what I am doing wrong. Thanks.
Here is my code:
{
“collection”:"****",
“aggregate”:[
{"$addFields":{
“ISOdate”: {
“$toDate”: {
“$toLong”: “$unix_date”
}
}

    }},
    {
        "$match":{
            "ISOdate":{"$gt":"{{ date }}")}
        }
    }
]

}