# Returning dateTime fields as timestamps

**URL:** <https://discuss.elastic.co/t/returning-datetime-fields-as-timestamps/16106>\
**Category:** Elasticsearch\
**Created:** [March 3, 2014, 1:53pm UTC](https://discuss.elastic.co/t/returning-datetime-fields-as-timestamps/16106 "2014-03-03T13:53:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Oliver\_B\_Fischer](https://avatars.discourse-cdn.com/v4/letter/o/f04885/32.png) [@Oliver\_B\_Fischer](https://discuss.elastic.co/u/Oliver_B_Fischer)\
**Post date:** [March 3, 2014, 1:53pm UTC](https://discuss.elastic.co/t/returning-datetime-fields-as-timestamps/16106/1 "2014-03-03T13:53:38Z")

</div>

Hi,

is there a way to return dateTime fields as unix timestamps and not in a  
ISO 8601 representation?

Thanks in advance

Oliver

--  
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/53148962.1000900%40swe-blog.net](https://groups.google.com/d/msgid/elasticsearch/53148962.1000900%40swe-blog.net).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Binh\_Ly\_2](https://avatars.discourse-cdn.com/v4/letter/b/d07c76/32.png) [@Binh\_Ly\_2](https://discuss.elastic.co/u/Binh_Ly_2)\
**Post date:** [March 3, 2014, 8:00pm UTC](https://discuss.elastic.co/t/returning-datetime-fields-as-timestamps/16106/2 "2014-03-03T20:00:53Z")

</div>

You should be able to do something like this on a date field:

{  
"script\_fields": {  
"epoch\_ms": {  
"script": "doc['datefield'].value"  
}  
}  
}

--  
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/19315c2c-e671-4241-b612-6c6785399a2b%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/19315c2c-e671-4241-b612-6c6785399a2b%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Oliver\_B\_Fischer](https://avatars.discourse-cdn.com/v4/letter/o/f04885/32.png) [@Oliver\_B\_Fischer](https://discuss.elastic.co/u/Oliver_B_Fischer)\
**Post date:** [March 3, 2014, 9:42pm UTC](https://discuss.elastic.co/t/returning-datetime-fields-as-timestamps/16106/3 "2014-03-03T21:42:55Z")

</div>

Thanks. I totally forgot that it exists...

Am 03.03.14 21:00, schrieb Binh Ly:

> You should be able to do something like this on a date field:
> 
> {  
> "script\_fields": {  
> "epoch\_ms": {  
> "script": "doc['datefield'].value"  
> }  
> }  
> }
> 
> --  
> 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/19315c2c-e671-4241-b612-6c6785399a2b%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/19315c2c-e671-4241-b612-6c6785399a2b%40googlegroups.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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/5314F75F.9000008%40swe-blog.net](https://groups.google.com/d/msgid/elasticsearch/5314F75F.9000008%40swe-blog.net).  
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, 1:46am UTC](https://discuss.elastic.co/t/returning-datetime-fields-as-timestamps/16106/4 "2017-07-06T01:46:02Z")

</div>


