webForumDet fria alternativet

Inom datum

1 svar · 460 visningar · startad av Dino

DinoMedlem sedan sep. 20011 914 inlägg
#1

SQLServer2005

Är det någon skillnad på:

o.Date BETWEEN @startdate AND @enddate

och

o.Date >= @startdate AND o.Date < dateadd(day,1,@enddate)
DinoMedlem sedan sep. 20011 914 inlägg
#2

Fick svar.

The difference is if you have time portion stored in table by using BETWEEN
caluse you might ge a wrong result as SQL Server 'removes' time portion.
On the other hand with your second approac you WON'T get a wrong data

Also, but you should be testing it, with the second option you may get
betterw performance as SQL Server most likely use and index on the column.I
do not say that it does not with the first one, just test it.

130 ms totalt · 3 externa anrop · v20260731065814-full.2b84b982
0 ms — hämta forumlista (cache)
0 ms — hämta statistik (cache)
127 ms — hämta tråd, inlägg och bilagor (db)