You are here: Re: day addition « MsSQL Server « IT news, forums, messages
Re: day addition

Posted by Hugo Kornelis on 11/03/06 22:10

On 2 Nov 2006 23:31:55 -0800, boetsid wrote:

>I saw in one of the solutions
>select dt + 1 from #anytable --like ( here dt is a
>datetime field )
>which one is more efficient or robust between
>dateadd(day, 1, dt) -- or only using
>dt + 1

Hi boetsid,

Both are equally robust. The behaviour of + with a datetime argument is
documented in Books Online, so it won't change withour prior warning.

ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/tsqlref9/html/4ba8baac-5f07-432c-87c5-d23e7011da55.htm,
example B.

If you want to know which is more efficient, then set up a loop to
repeat this calculation a few million times. Run it twice, using the
different techniques, and compare results. I don't expect that you'll
find any measurable difference, though.

--
Hugo Kornelis, SQL Server MVP

 

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

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