1dg618
2011-11-08 23:10:59 UTC
Usually, I don't have to worry about the time in a date, but it does
not mean a time isn't there. Usually, the dates are passed into a
script and used in the query. The format is yyyyMMdd.
I like using (1) because it seems to be more efficient (i.e. according
to a query plan).
(2) seems to be inefficient.
(1) WHERE a.date >= '20111108' AND date < dateadd(dd, 1, '20111108')
or
(2) WHERE CONVERT(VARCHAR, a.date, 112) = '20111108'
Is there a more efficient way to compare dates?
not mean a time isn't there. Usually, the dates are passed into a
script and used in the query. The format is yyyyMMdd.
I like using (1) because it seems to be more efficient (i.e. according
to a query plan).
(2) seems to be inefficient.
(1) WHERE a.date >= '20111108' AND date < dateadd(dd, 1, '20111108')
or
(2) WHERE CONVERT(VARCHAR, a.date, 112) = '20111108'
Is there a more efficient way to compare dates?