Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server 2008 SYSDATETIME returns wrong date

When I execute a select with SYSDATETIME() it gives me date two days in the past! Three of the date functions give me dates in the past and three give me the correct date. See below.

SELECT SYSDATETIME(),
       SYSDATETIMEOFFSET(),
       SYSUTCDATETIME(),
       CURRENT_TIMESTAMP,
       GETDATE(),
       GETUTCDATE()  
==================================
2011-10-17 10:41:00.4521484
2011-10-17 10:41:00.4521484 -04:00
2011-10-17 14:41:00.4521484
2011-10-19 10:41:00.447
2011-10-19 10:41:00.447
2011-10-19 14:41:00.45

I am using MS SQLServer 2008 and the JDBC 3.0 driver:

DatabaseProductName: MICROSOFT SQL SERVER
DriverName: Microsoft SQL Server JDBC Driver 3.0
getDatabaseProductName: Microsoft SQL Server
getDatabaseProductVersion: 10.50.1600
getDriverVersion: 3.0.1301.101
getDriverMajorVersion: 3
getDriverMinorVersion: 0
getDriverName: Microsoft SQL Server JDBC Driver 3.0

Any ideas what is going on here?

like image 629
user1003453 Avatar asked Jan 20 '26 11:01

user1003453


1 Answers

The Microsoft JDBC Driver for SQL Server does not support JRE 1.7. I faced same issue while working with MSSQL server and JRE-1.7. Use hot fix(worked for me) released by Microsoft to resolve your issue.

The hotfix is now available. http://blogs.msdn.com/b/jdbcteam/archive/2012/01/20/hotfix-available-for-date-issue-when-using-jre-1-7.aspx

Please use compatibility information from above article and install appropriate fix according to your Application.

Hope This helps :) Cheers

like image 96
cloud_geek Avatar answered Jan 23 '26 02:01

cloud_geek



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!