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

Jim Lawrence accessd at shaw.ca
Fri Apr 9 05:01:31 CDT 2010


Are you passing the parameter as a sring or a date? I never use dates for
obvious reasons.

Jim



-----Original Message-----
From: dba-sqlserver-bounces at databaseadvisors.com
[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of jwcolby
Sent: Thursday, April 08, 2010 1:44 PM
To: Access Developers discussion and problem solving; Sqlserver-Dba; VBA
Subject: [dba-SQLServer] C# Date conversion going in to a stored procedure

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
_______________________________________________
dba-SQLServer mailing list
dba-SQLServer at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
http://www.databaseadvisors.com




More information about the dba-SQLServer mailing list