Date Range Parameter


#1

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


#2

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 }}


#3

Hi BigFF,

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


#4

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.


#5

Hi Avinash,

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

Hope it helps!

Abed


#6

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


#7

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 }}"
            }
        }
    }
}

#8

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


#9

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