# Searching by date range on field having timestamp doesn't returns me documents

**URL:** https://discuss.elastic.co/t/searching-by-date-range-on-field-having-timestamp-doesnt-returns-me-documents/21985
**Category:** Elasticsearch
**Created:** [February 5, 2015, 8:44am UTC](https://discuss.elastic.co/t/searching-by-date-range-on-field-having-timestamp-doesnt-returns-me-documents/21985 "2015-02-05T08:44:54Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Paresh\_Behede](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paresh_behede/32/937_2.png) [@Paresh\_Behede](https://discuss.elastic.co/u/Paresh_Behede)
#### Post date: [February 5, 2015, 8:44am UTC](https://discuss.elastic.co/t/searching-by-date-range-on-field-having-timestamp-doesnt-returns-me-documents/21985/1 "2015-02-05T08:44:54Z")

</div>

Hi Team,

I want to search or get documents between the date range provided, my  
document consists 1 field with name created having mapping as:  
"created" : {

```
        "type" : "date",
        "format" : "dateOptionalTime"

```

}

& we store unix timestamp in this field. now when I query against this field with date (yyyy-mm-dd) it doesn't returns me any documents even if documents with that date converted into timestamp exists in ES.

I am running below query against my ES:

POST \_search  
{  
"query": {"range": {  
"created": {  
"gt": "2014-01-01T00:00:00Z",  
"lt": "2014-02-28T00:00:00Z"  
}  
}}  
}

Now there are many documents in this range but created field has timestamp stored instead of date...per documentation on website I guess this should be possible...

@see: [http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/\_ranges.html#\_ranges\_on\_dates](http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/_ranges.html#_ranges_on_dates)

Can any body help me with this issue?

Thanks in advance...

Regards,

Paresh Behede

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/a57e2522-625a-4e35-a462-cb0f2e2fb7a7%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/a57e2522-625a-4e35-a462-cb0f2e2fb7a7%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![masaru](https://avatars.discourse-cdn.com/v4/letter/m/a9a28c/32.png) [@masaru](https://discuss.elastic.co/u/masaru)
#### Post date: [February 5, 2015, 9:12am UTC](https://discuss.elastic.co/t/searching-by-date-range-on-field-having-timestamp-doesnt-returns-me-documents/21985/2 "2015-02-05T09:12:25Z")

</div>

Hi,

You are using unix timestamp as is(seconds since epoch) instead of milliseconds since epoch in your documents, perhaps?

Masaru

On February 5, 2015 at 17:45:01, Paresh Behede ([paresh2711@gmail.com](mailto:paresh2711@gmail.com)) wrote:

> Hi Team,
> 
> I want to search or get documents between the date range provided, my  
> document consists 1 field with name created having mapping as:  
> "created" : {
> 
> "type" : "date",  
> "format" : "dateOptionalTime"  
> }
> 
> & we store unix timestamp in this field. now when I query against this field with date (yyyy-mm-dd)  
> it doesn't returns me any documents even if documents with that date converted into timestamp  
> exists in ES.
> 
> I am running below query against my ES:
> 
> POST \_search  
> {  
> "query": {"range": {  
> "created": {  
> "gt": "2014-01-01T00:00:00Z",  
> "lt": "2014-02-28T00:00:00Z"  
> }  
> }}  
> }
> 
> Now there are many documents in this range but created field has timestamp stored instead  
> of date...per documentation on website I guess this should be possible...
> 
> @see: [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/_ranges.html#_ranges_on_dates)
> 
> Can any body help me with this issue?
> 
> Thanks in advance...
> 
> Regards,
> 
> Paresh Behede
> 
> --  
> You received this message because you are subscribed to the Google Groups "elasticsearch"  
> group.  
> To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/a57e2522-625a-4e35-a462-cb0f2e2fb7a7%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/a57e2522-625a-4e35-a462-cb0f2e2fb7a7%40googlegroups.com).  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/etPan.54d33435.4db127f8.1c2%40citra.local](https://groups.google.com/d/msgid/elasticsearch/etPan.54d33435.4db127f8.1c2%40citra.local).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [July 6, 2017, 12:34am UTC](https://discuss.elastic.co/t/searching-by-date-range-on-field-having-timestamp-doesnt-returns-me-documents/21985/3 "2017-07-06T00:34:52Z")

</div>


