# Date time with millisecond

**URL:** <https://discuss.elastic.co/t/date-time-with-millisecond/10085>\
**Category:** Elasticsearch\
**Created:** [December 17, 2012, 2:46am UTC](https://discuss.elastic.co/t/date-time-with-millisecond/10085 "2012-12-17T02:46:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ashutosh\_Sharma](https://avatars.discourse-cdn.com/v4/letter/a/c67d28/32.png) [@Ashutosh\_Sharma](https://discuss.elastic.co/u/Ashutosh_Sharma)\
**Post date:** [December 17, 2012, 2:46am UTC](https://discuss.elastic.co/t/date-time-with-millisecond/10085/1 "2012-12-17T02:46:20Z")

</div>

Hi All,

I have a question regarding the index and search of the date time field  
which store date with millisecond. Is there any known problem or issue if I  
store the millisecond? I am using "yyyyMMdd’T’HHmmss.SSSZ" date format to  
store the datetime value. As per my understanding, if we store the date  
value with millisecond granularity, then the index size will be bigger than  
if we don't store the millisecond. As there will be less number of unique  
values. Searching is also get affected if we store millisecond data as  
there are more number of docs to search.

Has someone face any issue with the date time with millisecond value. I  
want to use the millisecond for the sorting of the results i.e. if there  
are 100 docs within a second then it should be sort by the millisecond  
value.

Please help me and provide your inputs.

Thanks  
Ashu

--

---

<div class="post-metadata">

**Author:** ![radu\_gheorghe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/radu_gheorghe/32/556_2.png) [@radu\_gheorghe](https://discuss.elastic.co/u/radu_gheorghe)\
**Post date:** [December 17, 2012, 12:13pm UTC](https://discuss.elastic.co/t/date-time-with-millisecond/10085/2 "2012-12-17T12:13:24Z")

</div>

Hi Ashu,

I've used millisecond timestamps and I didn't have any issues. Of course,  
the index size would be slightly larger, but if you need millisecond  
granularity, I think you should go for it.

Sure, sorting on date will be slower because there will be more unique  
values to sort. But then, that's what you want in the first place, so it's  
not like you're wasting resources.

## Best regards, Radu

[http://sematext.com/](http://sematext.com/) -- Elasticsearch -- Solr -- Lucene

On Mon, Dec 17, 2012 at 4:46 AM, Ashutosh Sharma [ashu1979@gmail.com](mailto:ashu1979@gmail.com) wrote:

> Hi All,
> 
> I have a question regarding the index and search of the date time field  
> which store date with millisecond. Is there any known problem or issue if I  
> store the millisecond? I am using "yyyyMMdd’T’HHmmss.SSSZ" date format to  
> store the datetime value. As per my understanding, if we store the date  
> value with millisecond granularity, then the index size will be bigger than  
> if we don't store the millisecond. As there will be less number of unique  
> values. Searching is also get affected if we store millisecond data as  
> there are more number of docs to search.
> 
> Has someone face any issue with the date time with millisecond value. I  
> want to use the millisecond for the sorting of the results i.e. if there  
> are 100 docs within a second then it should be sort by the millisecond  
> value.
> 
> Please help me and provide your inputs.
> 
> Thanks  
> Ashu
> 
> --

--

---

<div class="post-metadata">

**Author:** ![phill](https://avatars.discourse-cdn.com/v4/letter/p/779978/32.png) [@phill](https://discuss.elastic.co/u/phill)\
**Post date:** [December 17, 2012, 8:35pm UTC](https://discuss.elastic.co/t/date-time-with-millisecond/10085/3 "2012-12-17T20:35:01Z")

</div>

On 12/17/2012 4:13 AM, Radu Gheorghe wrote:

> Hi Ashu,
> 
> I've used millisecond timestamps and I didn't have any issues. Of  
> course, the index size would be slightly larger, but if you need  
> millisecond granularity, I think you should go for it.
> 
> Sure, sorting on date will be slower because there will be more unique  
> values to sort. But then, that's what you want in the first place, so  
> it's not like you're wasting resources.  
> Only if the data includes more actual, not just because there might be  
> more values.

If you are using a real date(stamp) field each sort comparison is the  
same because each is a long, whether the number stored and sorted  
resolves to a whole second or a fractional second.  
The values are actually stored as a Long.

-Paul

--

---

<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:59am UTC](https://discuss.elastic.co/t/date-time-with-millisecond/10085/4 "2017-07-06T02:59:34Z")

</div>


