# Convert a column in csv to hour time

**URL:** <https://discuss.elastic.co/t/convert-a-column-in-csv-to-hour-time/163098>\
**Category:** Logstash\
**Created:** [January 6, 2019, 10:47pm UTC](https://discuss.elastic.co/t/convert-a-column-in-csv-to-hour-time/163098 "2019-01-06T22:47:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fadihaddad](https://avatars.discourse-cdn.com/v4/letter/f/4bbf92/32.png) [@fadihaddad](https://discuss.elastic.co/u/fadihaddad)\
**Post date:** [January 6, 2019, 10:47pm UTC](https://discuss.elastic.co/t/convert-a-column-in-csv-to-hour-time/163098/1 "2019-01-06T22:47:07Z")

</div>

![excel](https://us1.discourse-cdn.com/elastic/original/3X/b/6/b6ec25493f5ba1fa53f0019f0210afb09726c4da.png)  
I have these 2 cells the first is Day which was converted fine using the date filter but the HOUR column is appearing as a random date time stamp with no hours

my logstash date config:

date {  
match =\> ["DAY", "M/d/yyyy", "M/dd/yyyy", "MM/d/yyyy", "MM/dd/yyyy"]  
target =\> "DAY"  
locale =\> "en"  
timezone =\> "UTC"

}  
date {  
match =\> ["HOUR", "H"]  
target =\> "HOUR"  
locale =\> "en"  
timezone =\> "UTC"

}  
how the hour appearing on elastic search  
"HOUR" : "2019-01-01T00:00:00.000Z",  
I want the hour column to appear as hours of each day

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [January 7, 2019, 9:38pm UTC](https://discuss.elastic.co/t/convert-a-column-in-csv-to-hour-time/163098/2 "2019-01-07T21:38:17Z")

</div>

```
ruby { code => 'event.set("HOUR", LogStash::Timestamp.new(event.get("DAY")+ 3600 * event.get("HOUR")))' }

```

Error handling is left as an exercise for the reader.

---

<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 4, 2019, 9:38pm UTC](https://discuss.elastic.co/t/convert-a-column-in-csv-to-hour-time/163098/3 "2019-02-04T21:38:20Z")

</div>

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