<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Answers to: Storing DateTime in database</title><link>https://answers.axonivy.com/questions/1238/storing-datetime-in-database</link><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;we use database (sqlserver) to store values.
One of those field is an ivy DateTime.
When we try to store it in the database we have this error :&lt;/p&gt;
&lt;p&gt;com.microsoft.sqlserver.jdbc.SQLServerException: The conversion of a varchar data type to a smalldatetime data type resulted in an out-of-range value.
    at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:216)
    at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1515)&lt;/p&gt;
&lt;p&gt;The ivy field is a ch.ivyteam.ivy.scripting.objects.DateTime and it must be stored in a smalldatetime filed from sqlserver (10.50.4000.0).&lt;/p&gt;
&lt;p&gt;What are we doing wrong ?&lt;/p&gt;</description><atom:link href="https://answers.axonivy.com/questions/1238/storing-datetime-in-database" rel="self"></atom:link><language>en</language><lastBuildDate>Mon, 30 Mar 2015 16:43:19 -0400</lastBuildDate><item><title>Comment by Peter Stöckli on Peter Stöckli's answer</title><link>https://answers.axonivy.com/questions/1238/storing-datetime-in-database#1242</link><description>&lt;p&gt;Have you tried using the jTDS driver for MSSQL? (You can switch the driver in use in the Databases configuration UI)&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Peter Stöckli</dc:creator><pubDate>Mon, 30 Mar 2015 16:43:19 -0400</pubDate><guid>https://answers.axonivy.com/questions/1238/storing-datetime-in-database#1242</guid></item><item><title>Comment by Peter Stöckli on Peter Stöckli's answer</title><link>https://answers.axonivy.com/questions/1238/storing-datetime-in-database#1241</link><description>&lt;p&gt;Hi
what is the language of the MSSQL DB User in use?&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Peter Stöckli</dc:creator><pubDate>Thu, 26 Mar 2015 10:24:07 -0400</pubDate><guid>https://answers.axonivy.com/questions/1238/storing-datetime-in-database#1241</guid></item><item><title>Comment by dbalasse on Peter Stöckli's answer</title><link>https://answers.axonivy.com/questions/1238/storing-datetime-in-database#1240</link><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;i've solved this by changing the DateTime to a java.sql.Date.  Then I format this date in a string with the right format ("yyyy-MM-dd hh:mm:ss").&lt;/p&gt;
&lt;p&gt;It worked well on my dev environment but on the client's TST env, the format was different, days and month were inverted ("yyyy-dd-MM hh:mm:ss")&lt;/p&gt;
&lt;p&gt;In the futur, what would be an "ivy" standard way to store Date ?&lt;/p&gt;
&lt;p&gt;Thanks for your answer.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">dbalasse</dc:creator><pubDate>Wed, 25 Mar 2015 16:45:06 -0400</pubDate><guid>https://answers.axonivy.com/questions/1238/storing-datetime-in-database#1240</guid></item><item><title>Answer by Peter Stöckli</title><link>https://answers.axonivy.com/questions/1238/storing-datetime-in-database/1239</link><description>&lt;p&gt;Hi there&lt;/p&gt;
&lt;p&gt;Possibilities I could think of:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Date is out of range for MS SQL. auto initialized DateTimes are '0001-01-01 00:00:00', but MS SQL accepts only a date between January 1, 1753 and December 31, 9999&lt;/li&gt;
&lt;li&gt;The language of the MS SQL user isn't english -&amp;gt; DateTime Format is different &lt;a href="https://msdn.microsoft.com/de-ch/library/ms174398%28v=sql.105%29.aspx"&gt;SET LANGUAGE&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Peter Stöckli</dc:creator><pubDate>Wed, 25 Mar 2015 16:34:53 -0400</pubDate><guid>https://answers.axonivy.com/questions/1238/storing-datetime-in-database/1239</guid></item></channel></rss>