t-SQL CAST date returns 2 days less
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
This is a bug in the JDBC driver not coping with the Date
datatype.
A hotfix is available
精彩评论