|
Posted by Chris.Cheney on 05/10/07 13:28
"Plamen Ratchev" <Plamen@SQLStudio.com> wrote in news:BjE0i.8597$Ut6.2872
@newsread1.news.pas.earthlink.net:
> Here is an alternative to Dan's method, just using only the datetime
> functions:
>
> WHERE
> SoldDate >= DATEADD(year, -1, DATEADD(month, DATEDIFF(month, 0,
> CURRENT_TIMESTAMP), 0))
> AND
> SoldDate < DATEADD(month, DATEDIFF(month, 0, CURRENT_TIMESTAMP), 0)
>
> HTH,
>
> Plamen Ratchev
> http://www.SQLStudio.com
>
Is it rash to assume that CURRENT_TIMESTAMP will not be called twice for
each row? Perhaps only twice for the whole query? If it is called more than
once (as implied by the query), there will be a problem if the query is run
at a time such that midnight on the last day of the month occurs between
two calls. Or have I missed something (which I admit is likely).
Navigation:
[Reply to this message]
|