# ScriptedField Time format question

**URL:** https://discuss.elastic.co/t/scriptedfield-time-format-question/23613
**Category:** Elasticsearch
**Created:** [May 12, 2015, 3:39pm UTC](https://discuss.elastic.co/t/scriptedfield-time-format-question/23613 "2015-05-12T15:39:18Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Adam\_Whittaker](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/adam_whittaker/32/75325_2.png) [@Adam\_Whittaker](https://discuss.elastic.co/u/Adam_Whittaker)
#### Post date: [May 12, 2015, 3:39pm UTC](https://discuss.elastic.co/t/scriptedfield-time-format-question/23613/1 "2015-05-12T15:39:18Z")

</div>

Hello,

I am trying to get something like the Hour of day bar histogram that is  
demonstrated on this page working:

> **[Kibana 4 Beta 3: Now More Filtery
	  	 | Elastic](https://www.elastic.co/blog/kibana-4-beta-3-now-more-filtery)**
>
> Kibana 4 Beta 3 is out! Along with the usual smattering of small fixes come a few knockout headliners. Once again, we offer you the choice to dive right in by grabbing it here: download Kibana 4 Beta ...

It says to create a scripted field based on the timestamp like this:

Integer.parseInt(new Date(doc['OpenedDate'].value).format("H"))

I added my datetime field (openedDate) but it gives me and error when i got  
to discover (an error occurred with your request).

I also tried swapping out my datetime field with the @timestamp field (as  
per the sample) but i got the same error.

Any help would be appreciated.

Thanks,

## -- Please update your bookmarks! We have moved to [https://discuss.elastic.co/](https://discuss.elastic.co/)

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/2e5f02bc-6841-41aa-aaaf-8abc85577a78%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/2e5f02bc-6841-41aa-aaaf-8abc85577a78%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 12:14am UTC](https://discuss.elastic.co/t/scriptedfield-time-format-question/23613/2 "2017-07-06T00:14:27Z")

</div>


