Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Where Date ...

Author  Topic 

o0o0o
Starting Member

1 Post

Posted - 2006-06-13 : 04:29:54
Which is more efficent and why:

1) where abs(datediff(day,@date,table1.date)) <1

2) where table1.date between @dateFrom and @dateTo

3) where table1.date >= @dateFrom and table1.date <= @dateTo

Thanks


cmdr_skywalker
Posting Yak Master

159 Posts

Posted - 2006-06-13 : 04:53:49
2 is converted to 3 in the execution plan.
1 uses more computation and does not use an index (that is, if you have index on the table1.date).
i'll use 2 or 3.

May the Almighty God bless us all!
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-06-13 : 05:27:05
If there is index on the date column then 2 and 3 are best to use

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -