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 out of DataTime

Author  Topic 

dew3it
Starting Member

14 Posts

Posted - 2009-04-13 : 10:18:06
Hi

I need to compare the date between column of two different table,
however column is of DateTime but I need to compare only the Date part.

Please advice.

dev

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-04-13 : 10:26:33

Where t1.datecol>=dateadd(day,datediff(day,0,t2.datecol),0) and t1.datecol<dateadd(day,datediff(day,0,t2.datecol),1)

Madhivanan

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

dew3it
Starting Member

14 Posts

Posted - 2009-04-13 : 10:55:37
Thanks madhivanan


dev
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-04-15 : 02:46:02
quote:
Originally posted by dew3it

Thanks madhivanan


dev


You are welcome

Madhivanan

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

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-04-15 : 02:59:26
Or this, if you are going to screw up indexes anyway.

WHERE DATEDIFF(DAY, t1.DateCol, t2.DateCol) = 0



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page
   

- Advertisement -