locked
value < today at 00:00:00 RRS feed

  • Question

  • Hi experts,

     

     I saw in a several sql code on my server being used :

     

    DATEADD(dd, DATEDIFF(dd, 0, getdate()), 0) 

     

    Is there a difference in terms of performance to use:

      convert (date, getdate())

     

     

    it looks cleare to me too

     

    Tuesday, April 10, 2018 2:17 PM

Answers

  • convert (date, getdate()) would be faster.

    The other is the way prior to SQL 2008 support of the Date data type.

    • Marked as answer by maca128 Tuesday, April 10, 2018 2:39 PM
    Tuesday, April 10, 2018 2:37 PM

All replies

  • There is no difference in performance.  I would definitely use the convert(date, getdate()) as it is much clearer/cleaner. The other syntax was needed before SQL 2008 because the date datatype was new in SQL 2008.

    Tom

    Tuesday, April 10, 2018 2:37 PM
  • convert (date, getdate()) would be faster.

    The other is the way prior to SQL 2008 support of the Date data type.

    • Marked as answer by maca128 Tuesday, April 10, 2018 2:39 PM
    Tuesday, April 10, 2018 2:37 PM