# Spark SQL : How to specify a date range in WHERE clause?

**URL:** <https://discuss.elastic.co/t/spark-sql-how-to-specify-a-date-range-in-where-clause/47240>\
**Category:** Elasticsearch\
**Tags:** es-hadoop\
**Created:** [April 13, 2016, 11:28am UTC](https://discuss.elastic.co/t/spark-sql-how-to-specify-a-date-range-in-where-clause/47240 "2016-04-13T11:28:14Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![Preeti\_Raj\_Buchhada](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/preeti_raj_buchhada/32/8971_2.png) [@Preeti\_Raj\_Buchhada](https://discuss.elastic.co/u/Preeti_Raj_Buchhada)\
**Post date:** [April 13, 2016, 11:28am UTC](https://discuss.elastic.co/t/spark-sql-how-to-specify-a-date-range-in-where-clause/47240/1 "2016-04-13T11:28:15Z")

</div>

Hello,

I've got some success working with Spark SQL CLI to access our ES data.  
Environment:  
**ES:** 1.3.2  
**es-hadoop:** elasticsearch-hadoop-2.2.0  
**Spark:** spark-1.4.1-bin-hadoop2.6

The pushdown feature is working great!

However, I'm stuck with how to specify a date range in the WHERE clause, so that it gets pushed down to ES?

I've tried:

```
SELECT count(member_id),member_id 
FROM data 
WHERE ( response_timestamp > CAST('2015-03-01' AS date) AND response_timestamp < CAST('2015-03-31' AS date) ) GROUP BY member_id ;

```

but it doesn't push down the range filter to ES.

Is this possible with the current es-hadoop version in the first place?  
Please help!

---

_[View the full topic](https://discuss.elastic.co/t/spark-sql-how-to-specify-a-date-range-in-where-clause/47240)._
