# Field type for unix timestamp

**URL:** https://discuss.elastic.co/t/field-type-for-unix-timestamp/48413
**Category:** Elasticsearch
**Created:** [April 26, 2016, 10:35am UTC](https://discuss.elastic.co/t/field-type-for-unix-timestamp/48413 "2016-04-26T10:35:20Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Dom\_Sie](https://avatars.discourse-cdn.com/v4/letter/d/9e8a1a/32.png) [@Dom\_Sie](https://discuss.elastic.co/u/Dom_Sie)
#### Post date: [April 26, 2016, 10:35am UTC](https://discuss.elastic.co/t/field-type-for-unix-timestamp/48413/1 "2016-04-26T10:35:20Z")

</div>

Hi,

we use ES 1.4.4  
We have three fields who stores a date [format is the unix timestamp; in example 1461668482]  
So far we save the field as a string - date detection is enabled.  
A "from-to date aggregation // gt&lt date range query" works anyway - even if the fields are defined as strings.

Now we want to use an integer or date field type.  
When date field type: with format "epoch\_second"

> > A formatter for the number of seconds since the epoch. Note, that this timestamp allows a max length of 10 chars, so only dates between 1653 and 2286 are supported. You should use a different date formatter in that case.

But this date format is not defined in ES 1.4.4

When we use an integer i dont think that the date aggregations // date range querys still work.

Which field type did you use / would use for store and querys on unix timestamps in ES 1.4.4 ?

---

<div class="post-metadata">

### Author: ![Bruce\_Ritchie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bruce_ritchie/32/9370_2.png) [@Bruce\_Ritchie](https://discuss.elastic.co/u/Bruce_Ritchie)
#### Post date: [April 26, 2016, 2:06pm UTC](https://discuss.elastic.co/t/field-type-for-unix-timestamp/48413/2 "2016-04-26T14:06:40Z")

</div>

We currently use 1.3.4 and just use the default date type without specifying the format and it seems to handle milliseconds-since-epoch timestamps correctly. 2.3.1 however has issues with timestamps in that format that are \> 13 digits.

---

<div class="post-metadata">

### Author: ![Dom\_Sie](https://avatars.discourse-cdn.com/v4/letter/d/9e8a1a/32.png) [@Dom\_Sie](https://discuss.elastic.co/u/Dom_Sie)
#### Post date: [April 27, 2016, 6:47am UTC](https://discuss.elastic.co/t/field-type-for-unix-timestamp/48413/3 "2016-04-27T06:47:57Z")

</div>

Thx for your answer.  
I will check the date range querys with the default data type - when i am put a 10 digit timestamp into a field with the mapping "type": "date" and no format-definition ES define this field as  
"type": "date",  
"format": "dateOptionalTime"  
now i must check the querys...

---

<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 5, 2017, 10:56pm UTC](https://discuss.elastic.co/t/field-type-for-unix-timestamp/48413/4 "2017-07-05T22:56:05Z")

</div>


