Error in plugin reporting – Conversion failed when converting date and/or time from character string


Follow

Symptoms

If you click on List Cases with a line chart view, you may see the following exception:

NOTE: See further below for a resolution.

Wasabi.Runtime.WasabiException (0x80004005): Conversion failed when converting date and/or time from character string.
SQL: SELECT DATEADD(MINUTE, -Plugin_13_Numbers.Num * 180, '2012-02-18T15:22:34Z') as dtSample FROM Plugin_13_Numbers WHERE ( Plugin_13_Numbers.Num < ? ) ORDER BY Plugin_13_Numbers.Num DESC
Params: I
1: 236
---> System.Data.SqlClient.SqlException: Conversion failed when converting date and/or time from character string.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlDataReader.HasMoreRows()
at System.Data.SqlClient.SqlDataReader.ReadInternal(Boolean setTimeout)
at System.Data.SqlClient.SqlDataReader.Read()
at System.Data.Common.DataAdapter.FillLoadDataRow(SchemaMapping mapping)
at System.Data.Common.DataAdapter.FillFromReader(DataSet dataset, DataTable datatable, String srcTable, DataReaderContainer dataReader, Int32 startRecord, Int32 maxRecords, DataColumn parentChapterColumn, Object parentChapterValue)
at System.Data.Common.DataAdapter.Fill(DataSet dataSet, String srcTable, IDataReader dataReader, Int32 startRecord, Int32 maxRecords)
at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
at Wasabi.Runtime.ADO.Command.Fill(DataSet ds)
at FogCreek.FogBugz.CCmd.ExecuteDataset()


Server stack trace:
at Wasabi.Runtime.Error.Raise(Int32 number, String source, String description, String helpfile, Nullable`1 helpcontext)
at FogCreek.FogBugz.CCmd.ExecuteDataset()
at FogCreek.FogBugz.Database.CSelectQuery.GetDataSet()
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.PrivateProcessMessage(Run timeMethodHandle md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext)


Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at FogCreek.FogBugz.Database.CSelectQuery.GetDataSet()
at FogCreek.FogBugz.CaseHistory.CaseHistory.GetDates(DateTime dtStart, DateTime dtStop, TimeSpan interval)
at FogCreek.FogBugz.Reporting.Reporting.GetTimeBasedXAxisValues(DateTime dtStart, DateTime dtStop, TimeSpan interval)
at FogCreek.FogBugz.Reporting.Reporting.BuildReportData(CFilter filter)
at FogCreek.FogBugz.Reporting.Reporting.PresentFilter(CFilter filter)
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.PrivateProcessMessage(Run timeMethodHandle md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext)


Exception rethrown at [1]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at FogCreek.FogBugz.Plugins.Interfaces.IPluginFilterView.PresentFilter(CFilter filter)
at FogCreek.FogBugz.__Global.DoListBugs(Boolean fGridView, Boolean fIgnoreMax, Int32 ixPageNum) in e:codehostedbuildFBFogBugz_8-6-50distributesrc-Websitelist.was:line 698

Resolution

This is usually caused by having the Compatibility level set too low for your database. To fix it, in SQL Server Management Studio:

  1. Connect to the appropriate instance.
  2. Expand Databases
  3. Right-click the “FogBugz” database and select ‘Properties’
  4. Go to ‘Option’
  5. There should be a compatibility mode dropdown there; select the highest available (100 for SQL 2008, 90 for 2005).
  6. Click OK

There is zero downtime involved in the change; it only changes how SQL Server interacts with the database and doesn’t change the database itself.

sql server compatibility