Re: Passing DateDiff rather than Actual Dates as Parameters
- From: Erland Sommarskog <esquel@xxxxxxxxxxxxx>
- Date: Thu, 1 Dec 2005 13:40:34 +0000 (UTC)
laurenq uantrell (laurenquantrell@xxxxxxxxxxx) 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@xxxxxxxxxxxxx
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
.
- References:
- Re: Passing DateDiff rather than Actual Dates as Parameters
- From: Terry Kreft
- Re: Passing DateDiff rather than Actual Dates as Parameters
- From: laurenq uantrell
- Re: Passing DateDiff rather than Actual Dates as Parameters
- Prev by Date: Re: Why upgrade to MS SQL Server (be it 2000 or 2005) from Access (say, 97)?
- Next by Date: Re: Can I install VS.net 2005 / VS.net 2002 / SQL 2005 / SQL 2000 in one PC win2000 sp4?
- Previous by thread: Re: Passing DateDiff rather than Actual Dates as Parameters
- Next by thread: Re: Passing DateDiff rather than Actual Dates as Parameters
- Index(es):
Relevant Pages
|