Reputation: 21
Can someone explain me why casting a datetime to date returns a 2 days prior date?
I just run into this, and need to understand.
Just execute this:
SELECT
CAST(FLOOR(CAST(GETDATE() AS float)) AS datetime) AS currDate,
CAST(CAST(FLOOR(CAST(GETDATE() AS float)) AS datetime) AS DATE) AS lessDays
In my Sql Server 2008 R2 Returns me this:
----------------------------------------------
| currDate | lessDays |
----------------------------------------------
| 2011-08-28 00:00:00.0 | 2011-08-26 |
----------------------------------------------
Thanks in advance
Upvotes: 2
Views: 733
Reputation: 453288
This is a bug in the JDBC driver not coping with the Date
datatype.
Upvotes: 1