Feeds:
Posts
Comments

Archive for August, 2009

Use the conversion at your discretion.

A where clause having the convert keyword to convert date to varchar and compare would decrease the query time tremendously and you might need to do that when you want to split the time from date.

To test, I once ran a query containing a number of convertions and it ran for over 8hrs.
Amusingly, the same query ran for about 2.5 hours without the conversion.

--Example of such a query with the convert keyword:
select a, b
from tbl nolock
where convert(varchar(10), dateField, 121) >= '2009-08-10'

--Optimizated/Alternative method 
declare @myDate datetime 
set @myDate = dateadd(day, 0 ,datediff(day,0, getdate()))
Select @myDate 

Similar Topics:
Find the end of month –
http://wp.me/pAchH-2t)

Read Full Post »