# How to convert strings to time format

**URL:** <https://discuss.elastic.co/t/how-to-convert-strings-to-time-format/255267>\
**Category:** Logstash\
**Created:** [November 12, 2020, 11:01pm UTC](https://discuss.elastic.co/t/how-to-convert-strings-to-time-format/255267 "2020-11-12T23:01:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stephenson](https://avatars.discourse-cdn.com/v4/letter/s/a183cd/32.png) [@Stephenson](https://discuss.elastic.co/u/Stephenson)\
**Post date:** [November 12, 2020, 11:01pm UTC](https://discuss.elastic.co/t/how-to-convert-strings-to-time-format/255267/1 "2020-11-12T23:01:31Z")

</div>

Hello everyone,  
Since a few months, I started working with logstash to small programs like reading a log.  
I have some trouble understanding the development.  
I have this line of log.

> 08:19:1915 , Error trae\_1dato

I need insert to database on SQL Server, a table with the next columns:  
Hour - type time  
message - type text

The problem is when I send the information to SQL Server from logstash, because the time is string.

I tried using grok like TIME, SECOND, TIMESTAMP\_ISO8601 instead GREEYDATA, use GREEYDATA because at the beginning only used it to send to email.

```
filter {
	if [message] =~ "Error" {
		grok {
			match => {"message" => ["%{GREEDYDATA:Hour} , %{GREEDYDATA:message}"]}
		}
	} else if [message] =~ "error" {
		grok {
			match => {"message" => ["%{GREEDYDATA:Hour} , %{GREEDYDATA:message}"]}
		}
	} else {
		drop {}
	}
}

```

---

<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 10, 2020, 11:01pm UTC](https://discuss.elastic.co/t/how-to-convert-strings-to-time-format/255267/2 "2020-12-10T23:01:33Z")

</div>

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