# Convert string type(coming from spark structured streaming) to datetime(2019-01-02 17:16:04) in Elastic search and apply aggregation

**URL:** <https://discuss.elastic.co/t/convert-string-type-coming-from-spark-structured-streaming-to-datetime-2019-01-02-1704-in-elastic-search-and-apply-aggregation/166308>\
**Category:** Elasticsearch\
**Created:** [January 30, 2019, 8:51am UTC](https://discuss.elastic.co/t/convert-string-type-coming-from-spark-structured-streaming-to-datetime-2019-01-02-1704-in-elastic-search-and-apply-aggregation/166308 "2019-01-30T08:51:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Radhika\_Maheshwari](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/radhika_maheshwari/32/40353_2.png) [@Radhika\_Maheshwari](https://discuss.elastic.co/u/Radhika_Maheshwari)\
**Post date:** [January 30, 2019, 8:51am UTC](https://discuss.elastic.co/t/convert-string-type-coming-from-spark-structured-streaming-to-datetime-2019-01-02-1704-in-elastic-search-and-apply-aggregation/166308/1 "2019-01-30T08:51:01Z")

</div>

Hi,  
I am using spark structured streaming and save my data to ES and want to create dashboard from Kibana.  
In spark , I have order data and I have created\_at field in spark, which is String type.  
I need to convert it into datetime.  
But in spark when I am doing this, I got converted into some long value in Elastic search for that date.  
check this :- [https://github.com/elastic/elasticsearch-hadoop/issues/1173](https://github.com/elastic/elasticsearch-hadoop/issues/1173)

So , My problem is How to convert string (created\_at) to date(created\_at) in Elastic search and apply aggreagations.

---

<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:** [February 27, 2019, 8:51am UTC](https://discuss.elastic.co/t/convert-string-type-coming-from-spark-structured-streaming-to-datetime-2019-01-02-1704-in-elastic-search-and-apply-aggregation/166308/2 "2019-02-27T08:51:12Z")

</div>

Closed on February 27, 2019, 8:51am UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
