|
Posted by Erland Sommarskog on 10/22/34 11:33
laurenq uantrell (laurenquantrell@hotmail.com) writes:
> Erland,
> Why pass it as a string and then convert it to a date? In your example
> you're passing the formatted date (Format(Date, "YYYYMMDD") ) as a
> string to the varchar parameter, then converting it to a date in
> @real_date? Why not just pass it to a datetime parameter in the first
> place and have the error reporting of the client deal with formatting
> problems rather than the vague-aries of SQL error reporting?
>
> @indate varchar(10)
> AS
> Declare @real_date datetime
> Select @real_date = Convert(datetime, @indate, 112)
Well, it wasn't me who suggested that, and I entirely agree with you.
Passing datetime values as strings is a poor idea.
--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
Navigation:
[Reply to this message]
|