|
|
|
SSC-Addicted
      
Group: General Forum Members
Last Login: Tuesday, March 29, 2011 2:59 PM
Points: 473,
Visits: 606
|
|
Comments posted to this topic are about the item Do you know your getdate()?
--------------------------------------------- Nothing is impossible. It is just a matter of time and money.
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: Friday, May 17, 2013 2:53 AM
Points: 1,528,
Visits: 359
|
|
thanks ... was really not aware of this stuff... also a good interview question...
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Tuesday, May 14, 2013 10:51 AM
Points: 37,
Visits: 586
|
|
| Is there a reason you chose not to perform the same tests on the GETUTCDATE function?
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Sunday, July 18, 2010 11:20 PM
Points: 1,
Visits: 21
|
|
Testing the precision of GETDATE()... instead of getting values 595 and 15.6521, i got 4262 -out of 10 million calls i got distinct 4262 values returned by GETDATE() and 3.33318 - what is the precision of the GETDATE() function
which is supposed to be true. i ran the given query in the post, which the answer is supposed to be true.
i ran the query against SQL SERVER 2008
if i am wrong somewhere, let me know
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Tuesday, January 01, 2013 11:12 PM
Points: 248,
Visits: 372
|
|
Buddies,
I am using SS2005 and I ran the first query: DECLARE @TimeStart DATETIME DECLARE @Time DATETIME DECLARE @TimeEnd DATETIME DECLARE @I INT DECLARE @Count INT SET @I = 0 SET @Count = 0 SET @TimeStart = GETDATE() SET @Time = @TimeStart WHILE @I < 10000000 BEGIN SET @TimeEnd = GETDATE() IF @TimeEnd <> @Time BEGIN SET @Count = @Count + 1 SET @Time = @TimeEnd END SET @I = @I + 1 END PRINT @Count PRINT DATEDIFF(millisecond, @TimeStart, @TimeEnd) / CAST(@Count AS REAL)
I have got the values: 6519 and 3.33379. I ran the same query again to re-verify, but I have got: 6518 and 3.3363. The precision is 3.33 for GETDATE() function.
How these values are vary (595 and 15.6521 - 6519 and 3.33379) ?
KSB ----------------------------- Thousands of candles can be lit from a single candle, and the life of the candle will not be shortened. Knowledge and happiness never decreases by being shared.” - Buddha
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Wednesday, August 24, 2011 6:08 AM
Points: 1,
Visits: 14
|
|
Same result ...
15020 and 3.3462
SQL 2005 Developer on Vista 64bit
Edit: Same test on SQL 2008 Developer on the same machine
2900 and 15.5941
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Tuesday, May 14, 2013 2:25 AM
Points: 179,
Visits: 210
|
|
I ran the same 2 tests on Win 7 64bit Quad core, 8GB Ram machine running SQL Server 2008 Developer 64bit. And got the following: GetDate(): 2604 values with precision 3.33333 milliseconds SysDateTime(): 13930 values with precision 1000 microseconds, (1 millisecond)
Judging by the rest of the comments so far it seems to be that XP can't hack it whilst latest OS' can (unless CPU cores played a part).
However in production you would never use XP, Vista or 7 to run your SQL Server so more interesting would be results on other Windows server versions.
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Thursday, March 03, 2011 5:58 AM
Points: 7,
Visits: 22
|
|
Some more SYSDATETIME Results: SQL 2008 R2 on Windows 7 x64: 1 ms SQL 2008 R2 on Win 2008 R2 on HyperV on Win 2008 R2: 15.5 ms SQL 2008 R2 on Win 2008 R2 on VMWare on Win 7 x64: 1.3 ms
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Tuesday, April 16, 2013 8:19 AM
Points: 12,
Visits: 107
|
|
... and another test
Win XP 32 bit SP3 SQL Server 2005 SP3 (9.0.4262) CPU 2 processors (Core duo)
4517 and 3.32809
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Tuesday, April 23, 2013 4:32 AM
Points: 1,
Visits: 14
|
|
| is the other instructions present in the code takes some millisecond ?
|
|
|
|