[dba-SQLServer] C# Date conversion going in to a stored procedure

jwcolby jwcolby at colbyconsulting.com
Thu Apr 8 15:44:13 CDT 2010


I have an issue where I am sending in a date from C# to a stored procedure in SQL Server.  I am 
looking at the data on the C# side, clear down into the parameter object.value and the data is a 
string which looks like: "12/22/2010 14:23:01".  When it gets into the Varchar(100) on the SQL 
Server side (in the stored procedure) the seconds have been stripped off.  I NEED the seconds.  It 
appears that SQL Server is "helpfully" noticing that the string is a date and doing a conversion for 
me, stripping the seconds in the process.

I have passed the date in as a string, as an actual date and so forth and in all cases, SQL Server 
strips off the seconds.

What do I need to do to cause SQL Server to stop "being helpful" and leave my seconds alone?

-- 
John W. Colby
www.ColbyConsulting.com



More information about the dba-SQLServer mailing list