# Time Field (Hours/Minutes) Format "HH:mm"

**URL:** https://discuss.elastic.co/t/time-field-hours-minutes-format-hh-mm/68448
**Category:** Elasticsearch
**Created:** [December 8, 2016, 3:42pm UTC](https://discuss.elastic.co/t/time-field-hours-minutes-format-hh-mm/68448 "2016-12-08T15:42:55Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![mehdi-aouadi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mehdi-aouadi/32/13644_2.png) [@mehdi-aouadi](https://discuss.elastic.co/u/mehdi-aouadi)
#### Post date: [December 8, 2016, 3:42pm UTC](https://discuss.elastic.co/t/time-field-hours-minutes-format-hh-mm/68448/1 "2016-12-08T15:42:55Z")

</div>

I need a field with HH:mm format. I mapped it in the index usgin a HH:mm Format :

`"hour_start" : { "type" : "date", "format" : "HH:mm" }`

I retrieve the values from a semicolon separated values file :

`valueA;valueB;21:00;otherValues`

I use an `exec` input command `cat` on the file and hen a `split` filter. The time field is retrieved correctly but when the field is indexed it generates an error both in logstash and elasticsearch :

```
MapperParsingException[failed to parse [hour_start]]; nested: IllegalArgumentException[Invalid format: "hour_start"];
        at org.elasticsearch.index.mapper.FieldMapper.parse(FieldMapper.java:329)
        at org.elasticsearch.index.mapper.DocumentParser.parseObjectOrField(DocumentParser.java:311)
        at org.elasticsearch.index.mapper.DocumentParser.parseValue(DocumentParser.java:438)
        at org.elasticsearch.index.mapper.DocumentParser.parseObject(DocumentParser.java:264)
        at org.elasticsearch.index.mapper.DocumentParser.parseDocument(DocumentParser.java:124)
        at org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:309)
        at org.elasticsearch.index.shard.IndexShard.prepareIndex(IndexShard.java:580)
        at org.elasticsearch.index.shard.IndexShard.prepareIndexOnPrimary(IndexShard.java:559)
        at org.elasticsearch.action.index.TransportIndexAction.prepareIndexOperationOnPrimary(TransportIndexAction.java:211)
        at org.elasticsearch.action.index.TransportIndexAction.executeIndexRequestOnPrimary(TransportIndexAction.java:223)
        at org.elasticsearch.action.bulk.TransportShardBulkAction.shardIndexOperation(TransportShardBulkAction.java:327)
        at org.elasticsearch.action.bulk.TransportShardBulkAction.shardOperationOnPrimary(TransportShardBulkAction.java:120)
        at org.elasticsearch.action.bulk.TransportShardBulkAction.shardOperationOnPrimary(TransportShardBulkAction.java:68)
        at org.elasticsearch.action.support.replication.TransportReplicationAction$PrimaryPhase.doRun(TransportReplicationAction.java:648)
        at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37)
        at org.elasticsearch.action.support.replication.TransportReplicationAction$PrimaryOperationTransportHandler.messageReceived(TransportReplicationAction.java:279)
        at org.elasticsearch.action.support.replication.TransportReplicationAction$PrimaryOperationTransportHandler.messageReceived(TransportReplicationAction.java:271)
        at org.elasticsearch.transport.RequestHandlerRegistry.processMessageReceived(RequestHandlerRegistry.java:77)
        at org.elasticsearch.transport.TransportService$4.doRun(TransportService.java:376)
        at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IllegalArgumentException: Invalid format: "hour_start"
        at org.joda.time.format.DateTimeParserBucket.doParseMillis(DateTimeParserBucket.java:187)
        at org.joda.time.format.DateTimeFormatter.parseMillis(DateTimeFormatter.java:826)
        at org.elasticsearch.index.mapper.core.DateFieldMapper$DateFieldType.parseStringValue(DateFieldMapper.java:366)
        at org.elasticsearch.index.mapper.core.DateFieldMapper.innerParseCreateField(DateFieldMapper.java:534)
        at org.elasticsearch.index.mapper.core.NumberFieldMapper.parseCreateField(NumberFieldMapper.java:241)
        at org.elasticsearch.index.mapper.FieldMapper.parse(FieldMapper.java:321)
        ... 22 more

```

And then the value is stored in the document with a full date format :

`hour_start:December 31st 1969, 21:00:00.000`

How to manage time field with only hours and minutes ?

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [December 12, 2016, 4:33am UTC](https://discuss.elastic.co/t/time-field-hours-minutes-format-hh-mm/68448/2 "2016-12-12T04:33:03Z")

</div>

This sounds like an ES question more than an LS one.

Have you tried `hour_minute` or `strict_hour_minute` from [https://www.elastic.co/guide/en/elasticsearch/reference/5.1/mapping-date-format.html](https://www.elastic.co/guide/en/elasticsearch/reference/5.1/mapping-date-format.html)

---

<div class="post-metadata">

### Author: ![mehdi-aouadi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mehdi-aouadi/32/13644_2.png) [@mehdi-aouadi](https://discuss.elastic.co/u/mehdi-aouadi)
#### Post date: [December 12, 2016, 10:13am UTC](https://discuss.elastic.co/t/time-field-hours-minutes-format-hh-mm/68448/3 "2016-12-12T10:13:11Z")

</div>

I updated the mapping using `strict_hour_minute` Date Format :  
`"hour_start" : { "type" : "date", "format" : "HH:mm" }`

It is working !

---

<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: [January 9, 2017, 10:13am UTC](https://discuss.elastic.co/t/time-field-hours-minutes-format-hh-mm/68448/4 "2017-01-09T10:13:26Z")

</div>

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