# How to create a date and hour field into a timestamp

**URL:** https://discuss.elastic.co/t/how-to-create-a-date-and-hour-field-into-a-timestamp/108213
**Category:** Logstash
**Created:** [November 18, 2017, 12:21am UTC](https://discuss.elastic.co/t/how-to-create-a-date-and-hour-field-into-a-timestamp/108213 "2017-11-18T00:21:47Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![pgervais](https://avatars.discourse-cdn.com/v4/letter/p/65b543/32.png) [@pgervais](https://discuss.elastic.co/u/pgervais)
#### Post date: [November 18, 2017, 12:21am UTC](https://discuss.elastic.co/t/how-to-create-a-date-and-hour-field-into-a-timestamp/108213/1 "2017-11-18T00:21:47Z")

</div>

I need to combine two fields , one of which contains a date field and the other an hour field into a timestamp .  
For example, the Date field : "01OCT17" i.e. 1'st of OCT 2017. The Hour field is a numeric value from 0-23.  
The Date field is called ObsDate and the hour field is called ObsDate. These fields are found in each csv input line.

I would like to combine them into something like 01/Oct/2017 03:00:00  
Any ideas would be great

---

<div class="post-metadata">

### Author: ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)
#### Post date: [November 21, 2017, 6:25am UTC](https://discuss.elastic.co/t/how-to-create-a-date-and-hour-field-into-a-timestamp/108213/2 "2017-11-21T06:25:37Z")

</div>

> The Date field is called ObsDate and the hour field is called ObsDate.

Assuming there's a typo in this sentence and that they're really in different fields:

```plaintext
mutate {
  add_field => {
    "timestamp" => "%{ObsDate} %{ObsHour}"
  }
}

```

You'll probably want to delete the two fields that were combined (which you can do with a `remove_field` option in the same filter).

Use a date filter to parse the string into a timestamp that'll get recognized as such by Elasticsearch.

---

<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: [December 19, 2017, 6:25am UTC](https://discuss.elastic.co/t/how-to-create-a-date-and-hour-field-into-a-timestamp/108213/3 "2017-12-19T06:25:39Z")

</div>

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