Hello,
In the code
SqlParameter dtDate =new SqlParameter("@.date",SqlDbType.SmallDateTime,4);dtDate.Value=Convert.ToDateTime(Session["date"].ToString());cmd.Parameters.Add(dtDate);
where the @.date parameter is defined as a SMALLDATETIME inside a stored procedure,
I cannot use a function such as "Convert.ToSmallDateTime" and it seems
a conversion from DateTime to SmallDateTime takes place anywhere within the code.
Eventually it works but I wonder if everything's ok with this code.
Is there anything wrong about it?
Thanks
Hi, there are some differences between DATETIME and SMALLDATETIME type in SQL: date range and time precision. However normally converting from 'valid' DATETIME(falls in the data range of SMALLDATETIME) data to SMALLDATETIME should not cause problem. Here are some userful links:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_da-db_9xut.asp
http://msdn.microsoft.com/library/en-us/acdata/ac_8_con_03_27c5.asp?frame=true
|||There is major difference between DateTime and SmallDateTime, the reason is resolution, SmallDateTime will not give you seconds and sometimes you can use it to remove duplicates because SQL Server will just trim the data. One word of caution I would not use it for standard date column. Hope this helps.
No comments:
Post a Comment