Friday, May 10, 2013

Where Am I Doing this wrong? TSQL IF Clause

I unmarked the answer because as I already stated this kind of predicate


WHERE SellEndDate = @SellEndDate


cannot be used for DATETIME column.


If it works it's because time part is zero. If time part is not zero, the predicate would not include it.


You need to do:



WHERE SellEndDate >= @SellEndDate and SellEndDate < dateadd(dd,1, @SellEndDate)





Kalman Toth Database & OLAP Architect sqlusa.com

New Book / Kindle: Pass SQL Exam 70-461 & Job Interview: Programming SQL Server 2012


No comments:

Post a Comment