Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
SamSquanch
Starting Member
1 Post |
Posted - 2011-10-19 : 11:06:23
|
When I execute a select with SYSDATETIME() it gives me date 2 days in the past!!! 3 of the date functions gives me dates in the past and 3 give me the correct date. See below.SELECT SYSDATETIME(), SYSDATETIMEOFFSET(), SYSUTCDATETIME(), CURRENT_TIMESTAMP, GETDATE(), GETUTCDATE()==================================2011-10-17 10:41:00.45214842011-10-17 10:41:00.4521484 -04:002011-10-17 14:41:00.45214842011-10-19 10:41:00.4472011-10-19 10:41:00.4472011-10-19 14:41:00.45I am using MS SQLServer 2008 and the JDBC 3.0 driver:DatabaseProductName: MICROSOFT SQL SERVER DriverName: Microsoft SQL Server JDBC Driver 3.0getDatabaseProductName: Microsoft SQL ServergetDatabaseProductVersion: 10.50.1600getDriverVersion: 3.0.1301.101getDriverMajorVersion: 3getDriverMinorVersion: 0getDriverName: Microsoft SQL Server JDBC Driver 3.0Any ideas what is going on here? |
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2011-10-19 : 11:32:10
|
My guess is the JDBC driver does not recognize or correctly interpret the SYSDATE functions. I get correct results using SSMS on the same version of SQL Server. |
|
|
paultech
Yak Posting Veteran
79 Posts |
Posted - 2011-10-20 : 10:41:40
|
Hello i suggest you to use:SQL Server 2008 obtains the date and time values by using the GetSystemTimeAsFileTime() Windows API. The accuracy depends on the computer hardware and version of Windows on which the instance of SQL Server is running. The precision of this API is fixed at 100 nanoseconds. The accuracy can be determined by using the GetSystemTimeAdjustment() Windows API. |
|
|
|
|
|