sqldatetime

.NET DateTime to SqlDateTime Conversion

While converting .NET DateTime (when is default(DateTime)) to SqlDateTime should I always check if the .NET date is between SqlDateTime.MinValue and SqlDateTime.MaxValue [or] Is there a good way to do this. ...

Inconsistent SQLDateTime Overflow with NHibernate

We have a very strange error that sometimes we get this error when we want to save something from our WCF service. The object that we are saving contains NO invalid datetimes, we all check them before we save. When we see this error the database hangs sometimes and the WCF is in a faulty state. When I restart the DB and the IIS web app w...

SqlDateTime overflow Error on simple LINQ, C# .Net Web Page

I have a simple page I'm creating that just inserts some data from textboxes in .Net using C#. I get the overflow error stating the date must be within a specific range. The text being entered in the txtBirthdate box would be something like: 01/01/1980. When debugging, the Client1 _Birthdate object shows {1/1/1980 12:00:00}. So as far a...

How to extract a Date from an SQLDateTime object in Mathematica

I am trying to do a plot of a time series with DateListPlot. I want to feed it a time series I obtain from an SQL database. When I retrieve the time series the list is composed of SQLDateTime entries that DateListPlot doesn't understand. In[24]:= t=SQLExecute[conn, "select timestamp,value from timeseries order by timestamp asc"] Out[...

SqlDateTime overflow on INSERT when date is correct using a Linq to SQL DataContext

Dear Linq experts, I get an SqlDateTime overflow error (Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.) when doing an INSERT using an Linq DataContext connected to SQL Server database when I do the SubmitChanges(). When I use the debugger the date value is correct. Even if I temporary update the code to set the date ...

SQLBulkCopy can't convert Time to DateTime

I am writing a small utility to copy a database from a proprietary ODBC database into a SQL Server database. Everything is working great, except when I use SQLBulkCopy to copy over the data. It works in most cases, but not when it's trying to copy a TIME field into a SQL DATETIME. I get this error: The given value of type TimeSpan fr...

Entity Framework and SqlDateTime overflow best practices

System.DateTime can take a wider range of values than SQL Server's DateTime. Hence there is class System.Data.SqlTypes.SqlDateTime which mimics the later. Consequently I would have expected Entity Framework to choose SqlDateTime, but it didn't. So my questions are... What are the best practices to insure that your DateTime values wi...