Home Forums SQL Server 2005 T-SQL (SS2K5) Datediff versus Convert for datetime comparison (ignoring time part) RE: Datediff versus Convert for datetime comparison (ignoring time part)

  • From what I've read, the DATEDIFF() method has proven to be more efficient.

    Overall, for SQL to use any index, it has to highly selective or a covering index: I suspect that's unlikey here.

    Of course you can avoid any manipulation on one of the columns by doing two manipulations on the other one :-). Then at least one of the columns is SARGable.

    I'd be suprised if the overhead of two persisted 8-byte columns is really worth it here, unless you do this type of thing a lot on those columns. Typically a little occasional CPU overhead is much better than permanent I/O overhead.

    Scott Pletcher, SQL Server MVP 2008-2010