You are here: Re: Passing DateDiff rather than Actual Dates as Parameters « MsSQL Server « IT news, forums, messages
Re: Passing DateDiff rather than Actual Dates as Parameters

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация