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 2005 Forums
 Transact-SQL (2005)
 Date Comparison

Author  Topic 

Thiyagu_04
Starting Member

37 Posts

Posted - 2008-11-18 : 04:56:04
Hi
one of my procedure checking date condition like this
"where convert(varchar,dt,101)=@t"
inside procedure many places i need to check this type of date condition.i am getting performance issue any feasible way to check the date condtion.

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-11-18 : 04:59:23
Try using

where dt>=dateadd(day,datediff(day,0,@t),0)
and dt<dateadd(day,datediff(day,0,@t),1)


Madhivanan

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

bjoerns
Posting Yak Master

154 Posts

Posted - 2008-11-18 : 05:01:15
declare @dt datetime = convert(datetime, @t, ...)
...
where dt = @dt
Go to Top of Page

lionofdezert
Aged Yak Warrior

885 Posts

Posted - 2008-11-18 : 05:01:47
madhi How can you say, statement you mentioned is faster then the described earlier.
Go to Top of Page

bjoerns
Posting Yak Master

154 Posts

Posted - 2008-11-18 : 05:03:38
Ah sorry, didn't get the 101 format. Anyway, store the results of madhivanan's calculations in variables first.
Go to Top of Page
   

- Advertisement -