c# - .NET DateTime to SqlDateTime Conversion -


When changing the .NET datetime (when it is default) in SqlDateTime, I should always check whether the .NET date Between SqlDateTime.MinValue and SqlDateTime.MaxValue [or] is a good way to do this.

Is it possible that the date can actually be outside of that boundary? Did this come from user input? If the answer to both of these questions is yes, you should always check - otherwise you are passing your application in error.

You can easily format your date to include in the SQL statement:

  var sqlFormattedDate = myDateTime.Date.ToString ("yyyy-MM-dd HH: mm: ss ");  

Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -