# JDBC Importer for Logstash is adding timezone to date time field

**URL:** <https://discuss.elastic.co/t/jdbc-importer-for-logstash-is-adding-timezone-to-date-time-field/37537>\
**Category:** Logstash\
**Created:** [December 18, 2015, 5:59am UTC](https://discuss.elastic.co/t/jdbc-importer-for-logstash-is-adding-timezone-to-date-time-field/37537 "2015-12-18T05:59:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Senz79](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/senz79/32/42874_2.png) [@Senz79](https://discuss.elastic.co/u/Senz79)\
**Post date:** [December 18, 2015, 5:59am UTC](https://discuss.elastic.co/t/jdbc-importer-for-logstash-is-adding-timezone-to-date-time-field/37537/1 "2015-12-18T05:59:02Z")

</div>

Hello  
I am using jdbc importer to extract data from SQL Server to Elasticsearch. I am sharing the structure and i got configuration OK with logstash configtest.

Now i am getting an weird issue there is an UsageDate field in my sql query and when I run the sql query on query analyzer i get proper date format as **2015-05-28 20:00:00.000** now when i upload the data using logstash it is converting the date to **2015-05-28 20:00:00 -0600**.

I am quite confused from where -0600 is concatenating. Also due to the issue when i map the index in kibana it is showing UsageDate as String. Please help i am stuck

> ` input {`  
> jdbc {  
> jdbc\_connection\_string =\> "jdbc:sqlserver://XXXXXXXXXXX:1433;databaseName=XXXX"  
> jdbc\_user =\> "XXXXX"  
> jdbc\_password =\> "XXXXXXXX"  
> jdbc\_validate\_connection =\> true  
> jdbc\_driver\_library =\> "XXXXXXXXXXX/sqljdbc4-3.0.jar"  
> jdbc\_driver\_class =\> "com.microsoft.sqlserver.jdbc.sqlserverdriver"  
> schedule =\> "0 \* \* \* \*"  
> statement =\> "declare @date datetime; declare @startdate datetime; declare @enddate datetime; set @date=getdate(); set @enddate = DATEADD(hh, DATEPART(HOUR, @date),Cast(Min(CONVERT(date, @date))as Datetime)); set @startdate=DATEADD(hh, -1, @enddate); Select DATEADD(hh, DATEPART(HOUR, @startdate), Cast(Min(CONVERT(date, @startdate))as Datetime)) UsageDate,'Tutoring' Module,'NoOfAvailablity' ModuleKey, (select Count(distinct timeslotid) UsageValue from [Tutoring].[tblAppointmentExtendedProperties] with (nolock) where OccurenceStartDate between @startdate and @enddate)"  
> }  
> }  
> output {  
> elasticsearch {  
> protocol =\> http  
> index =\> "epssql"  
> document\_type =\> "epssql"  
> host =\> "XXXXXXXXXXXX"  
> port =\> "9200"  
> }  
> stdout { codec =\> rubydebug }  
> }

---

<div class="post-metadata">

**Author:** ![krushnat\_khawale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/krushnat_khawale/32/6652_2.png) [@krushnat\_khawale](https://discuss.elastic.co/u/krushnat_khawale)\
**Post date:** [December 18, 2015, 7:26am UTC](https://discuss.elastic.co/t/jdbc-importer-for-logstash-is-adding-timezone-to-date-time-field/37537/2 "2015-12-18T07:26:23Z")

</div>

**Yes, I'm haveing same issue, Has anyone here fixed this?**

---

<div class="post-metadata">

**Author:** ![Senz79](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/senz79/32/42874_2.png) [@Senz79](https://discuss.elastic.co/u/Senz79)\
**Post date:** [December 18, 2015, 12:02pm UTC](https://discuss.elastic.co/t/jdbc-importer-for-logstash-is-adding-timezone-to-date-time-field/37537/3 "2015-12-18T12:02:18Z")

</div>

Any Pointers !! Please Assist

---

<div class="post-metadata">

**Author:** ![wiibaa](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wiibaa/32/44931_2.png) [@wiibaa](https://discuss.elastic.co/u/wiibaa)\
**Post date:** [December 18, 2015, 12:13pm UTC](https://discuss.elastic.co/t/jdbc-importer-for-logstash-is-adding-timezone-to-date-time-field/37537/4 "2015-12-18T12:13:38Z")

</div>

Hello,

Having field in UTC in Kibana is mandatory, the issue is how the jdbc input is interpreting the date field when reading from the database and converting for Kibana.  
your issue seems similar to the reported issue on the plugin [https://github.com/logstash-plugins/logstash-input-jdbc/issues/89](https://github.com/logstash-plugins/logstash-input-jdbc/issues/89)

where the database is using UTC but the logstash agent interpret is in a different timezone and reconvert it to UTC causing the timelapse.

Updating the plugin and configuring the timezone to use when reading from the database should help you in resolving this I hope.

---

<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, 5:17am UTC](https://discuss.elastic.co/t/jdbc-importer-for-logstash-is-adding-timezone-to-date-time-field/37537/5 "2017-07-06T05:17:53Z")

</div>


