# Logstash-jdbc-input Timezone issue

**URL:** <https://discuss.elastic.co/t/logstash-jdbc-input-timezone-issue/58783>\
**Category:** Logstash\
**Created:** [August 24, 2016, 8:10am UTC](https://discuss.elastic.co/t/logstash-jdbc-input-timezone-issue/58783 "2016-08-24T08:10:46Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![slion](https://avatars.discourse-cdn.com/v4/letter/s/d6d6ee/32.png) [@slion](https://discuss.elastic.co/u/slion)\
**Post date:** [August 24, 2016, 8:10am UTC](https://discuss.elastic.co/t/logstash-jdbc-input-timezone-issue/58783/1 "2016-08-24T08:10:46Z")

</div>

When I use logstash-jdbc-input plugin to import data from Sql Server, the imported time is utc-based which is not same with my origin data. How to solve this?

Second, the sql\_last\_value always logged in UTC timezone either, how can I log it in my local timezone?  
Thanks in advance.

---

<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:** [August 24, 2016, 8:37am UTC](https://discuss.elastic.co/t/logstash-jdbc-input-timezone-issue/58783/2 "2016-08-24T08:37:28Z")

</div>

> When I use logstash-jdbc-input plugin to import data from Sql Server, the imported time is utc-based which is not same with my origin data. How to solve this?

Elasticsearch always stores timestamps in UTC. Quoting [https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-date-format.html:](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-date-format.html:)

"Elasticsearch uses a set of preconfigured formats to recognize and parse these strings into a long value representing milliseconds-since-the-epoch in UTC."

> Second, the sql\_last\_value always logged in UTC timezone either, how can I log it in my local timezone?

I don't think you can. Why does this matter?

---

<div class="post-metadata">

**Author:** ![slion](https://avatars.discourse-cdn.com/v4/letter/s/d6d6ee/32.png) [@slion](https://discuss.elastic.co/u/slion)\
**Post date:** [August 24, 2016, 8:53am UTC](https://discuss.elastic.co/t/logstash-jdbc-input-timezone-issue/58783/3 "2016-08-24T08:53:31Z")

</div>

Actually I use it to sync my data to ES according to the timestamp like below:

```
    statement => "SELECT * FROM t_Expert WHERE operateTime>:sql_last_value"

```

If their timezone is different, I can't use the sql.

---

<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:** [August 24, 2016, 10:58am UTC](https://discuss.elastic.co/t/logstash-jdbc-input-timezone-issue/58783/4 "2016-08-24T10:58:06Z")

</div>

You can convert local timestamps to UTC in the query. My T-SQL is rusty so I don't have any example.

---

<div class="post-metadata">

**Author:** ![moe55555](https://avatars.discourse-cdn.com/v4/letter/m/58956e/32.png) [@moe55555](https://discuss.elastic.co/u/moe55555)\
**Post date:** [November 26, 2016, 10:46am UTC](https://discuss.elastic.co/t/logstash-jdbc-input-timezone-issue/58783/5 "2016-11-26T10:46:23Z")

</div>

Hi Slion , currently I encounter same issue , did you find out the solution ?

---

<div class="post-metadata">

**Author:** ![Nelson\_Nunes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nelson_nunes/32/14040_2.png) [@Nelson\_Nunes](https://discuss.elastic.co/u/Nelson_Nunes)\
**Post date:** [December 21, 2016, 8:31am UTC](https://discuss.elastic.co/t/logstash-jdbc-input-timezone-issue/58783/6 "2016-12-21T08:31:27Z")

</div>

Same issue here.

How to solve this issue ?

thanks,

---

<div class="post-metadata">

**Author:** ![slion](https://avatars.discourse-cdn.com/v4/letter/s/d6d6ee/32.png) [@slion](https://discuss.elastic.co/u/slion)\
**Post date:** [January 6, 2017, 7:56am UTC](https://discuss.elastic.co/t/logstash-jdbc-input-timezone-issue/58783/7 "2017-01-06T07:56:59Z")

</div>

Not yet. Seems the param is useless.

---

<div class="post-metadata">

**Author:** ![endersonmaia](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/endersonmaia/32/17308_2.png) [@endersonmaia](https://discuss.elastic.co/u/endersonmaia)\
**Post date:** [April 12, 2017, 7:10pm UTC](https://discuss.elastic.co/t/logstash-jdbc-input-timezone-issue/58783/8 "2017-04-12T19:10:26Z")

</div>

I used the `jdbc_default_timezone` to define the timzone for the database I'm connecting, and it worked for me.

Now the `@timestamp` and my table's `date` column are in the same timezone, so I can use `date > :sql_last_value` in my `statement` for `jdbc-input-plugin`.

---

<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, 4:27am UTC](https://discuss.elastic.co/t/logstash-jdbc-input-timezone-issue/58783/9 "2017-07-06T04:27:06Z")

</div>


