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

Gustav Brock Gustav at cactus.dk
Fri Apr 9 01:59:25 CDT 2010


Hi John

Why not declare the parameter as Date? That will accept values with seconds and milliseconds.

/gustav

>>> jwcolby at colbyconsulting.com 08-04-2010 22:44 >>>
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-VB mailing list