![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
there is a program running, which sends information to two other programs. This information is a timestamp of the program in datetime format, which has it's own clock. The clock is incremented each 5 seconds of the program, which corespondes to aprox. one second of the real time. It means, each on second of real time, the computer time is updated +5 seconds. |
|
What I can not UNDERSTAND, why sometimes the time is equal, or sometimes is ALMOST equal (within the diff of miliseconds), and why sometimes the time is like this(!!!) : getdate() = '2007.04.25 10:59:55.000' prm_recieved = '2007.04.25 10:00:00.000' |
#3
| |||
| |||
|
|
So you have an application that modifies the computer clock every second, and now you are asking why: |
No ... of course, I'm not confused about the time changes 
|
getdate() = '2007.04.25 10:59:55.000' prm_recieved = '2007.04.25 10:00:00.000' getdate() does not always reflect you recently updated system time. I guess the answer is that there is not really reason that Windows and SQL Server would behave the way you may want it to in this very special scenario. One reason that getdate() apparently lags behind is that getdate() has a resolution of 3.33 ms which after all is quite a long time in a computer. Assuming that SQL Server reads the system clock every 3.33 ms, getdate() could seemingly lag behind your manipulated time. |

#4
| |||
| |||
|
|
So ... that means for me as fallow: The getdate() is not taking the current system time, only the buffered SQLServer system time. |
|
That means as well, that the time between changing system time, writing into log (application) and calling procedure in DB, until this position where the getdate() is called, MUST be shorter than a maximum time of 3.33 ms. |
Well, this is not I was thinking getdate() is doing![]() Is the current_timestamp function behaviour exactly in this way? (probably yes, since in BOL says that this is the same as getdate()) |
#5
| |||
| |||
|
|
The getdate() is not taking the current system time, only the buffered SQLServer system time. I like to stress that is my own speculation of how the internals work. That means as well, that the time between changing system time, writing into log (application) and calling procedure in DB, until this position where the getdate() is called, MUST be shorter than a maximum time of 3.33 ms. If my theory is correct, yes, this appears to be a correct conclusion. |
#6
| |||
| |||
|
|
I was thinkig about one more thing ... Is there any way, to force sql server to refresh it's time? Let's say, that by the procedure call, I will force him, to refresh it's time ... will it be possible somehow? |
#7
| |||||
| |||||
|
|
to affect this behaviour is about nil. Who knows, maybe there is a trace flag, but don't stay up all night looking for it. |
Have other things to do as well 
|
If you are on SQL 2005, you could write a CLR function which retrieves |
|
If you are on SQL 2000, you would have to write an extended stored |
|
procedure, which may not be performant enough. (There is quite a cost for the eontext switch.) |

|
But getdate() seems dead in the water when you are living in the fast lane like you do. |
![]() |
| Thread Tools | |
| Display Modes | |
| |