OK, OP already has found solution:
Quote:
I got the solution. The issue was that, the date part was getting converted to datetime2, but with time as 00:00:00. Then I did in the following way, and it worked.
select *
from Table1
where [Date1] >= DATEADD(MS,-1,CAST(DATEADD(DD,1,@toDate) AS datetime2))
But i have to point out that - as
MSDN documentation[
^] states - an implicit conversion between
date
and
datetime2
data types is possible by using
CAST
and
CONVERT
functions.
A
datetime2 (Transact-SQL)[
^] data type is well known as
an extension of the existing datetime (Transact-SQL)[^] type that has a larger date range, a larger default fractional precision, and optional user-specified precision, but
date[
^] data type represents date without time part. So, the result of implicit conversion from
date
to
datetime2
is date with time equal to zero!