# Searching on a date

**URL:** https://discuss.elastic.co/t/searching-on-a-date/12013
**Category:** Elasticsearch
**Created:** [May 17, 2013, 2:25pm UTC](https://discuss.elastic.co/t/searching-on-a-date/12013 "2013-05-17T14:25:31Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![dantuff](https://avatars.discourse-cdn.com/v4/letter/d/e79b87/32.png) [@dantuff](https://discuss.elastic.co/u/dantuff)
#### Post date: [May 17, 2013, 2:25pm UTC](https://discuss.elastic.co/t/searching-on-a-date/12013/1 "2013-05-17T14:25:31Z")

</div>

Is there a way to search on a date or a number of dates.

I have a date field that is stored in the index as so:

"mydate":{  
"type" : "date",  
"index" : "not\_analyzed",  
"format" : "yyyy-MM-dd'T'HH:mm:ssZ||yyyy-MM-dd"  
},

but I want to be able to search for a document that has a particular date  
(not a range query) i.e.

myDate:2012-05-14

or even search for documents that have these partiuclar dates

myDate:2012-05-14 OR myDate:2013-05-14

Is it possible to index a text version of the field and remove the time  
stamp then I can treat it as this particualr date query as a text query.

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [May 17, 2013, 2:33pm UTC](https://discuss.elastic.co/t/searching-on-a-date/12013/2 "2013-05-17T14:33:57Z")

</div>

IMHO, you should remove it on client side prior to indexing.  
Otherwise, using range queries is fine with dates. Why don't you want to use Range?

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 17 mai 2013 à 16:25, es newbie [dan.tuffery@gmail.com](mailto:dan.tuffery@gmail.com) a écrit :

> Is there a way to search on a date or a number of dates.
> 
> I have a date field that is stored in the index as so:
> 
> "mydate":{  
> "type" : "date",  
> "index" : "not\_analyzed",  
> "format" : "yyyy-MM-dd'T'HH:mm:ssZ||yyyy-MM-dd"  
> },
> 
> but I want to be able to search for a document that has a particular date (not a range query) i.e.
> 
> myDate:2012-05-14
> 
> or even search for documents that have these partiuclar dates
> 
> myDate:2012-05-14 OR myDate:2013-05-14
> 
> Is it possible to index a text version of the field and remove the time stamp then I can treat it as this particualr date query as a text query.
> 
> --  
> 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).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![dantuff](https://avatars.discourse-cdn.com/v4/letter/d/e79b87/32.png) [@dantuff](https://discuss.elastic.co/u/dantuff)
#### Post date: [May 17, 2013, 3:02pm UTC](https://discuss.elastic.co/t/searching-on-a-date/12013/3 "2013-05-17T15:02:19Z")

</div>

You're right I can use range query for this search. Thanks

On Friday, May 17, 2013 3:25:31 PM UTC+1, es newbie wrote:

> Is there a way to search on a date or a number of dates.
> 
> I have a date field that is stored in the index as so:
> 
> "mydate":{  
> "type" : "date",  
> "index" : "not\_analyzed",  
> "format" : "yyyy-MM-dd'T'HH:mm:ssZ||yyyy-MM-dd"  
> },
> 
> but I want to be able to search for a document that has a particular date  
> (not a range query) i.e.
> 
> myDate:2012-05-14
> 
> or even search for documents that have these partiuclar dates
> 
> myDate:2012-05-14 OR myDate:2013-05-14
> 
> Is it possible to index a text version of the field and remove the time  
> stamp then I can treat it as this particualr date query as a text query.

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:36am UTC](https://discuss.elastic.co/t/searching-on-a-date/12013/4 "2017-07-06T02:36:01Z")

</div>


