Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trouble Making ServerTime "tick" 2

Status
Not open for further replies.

toddOne

Programmer
Jul 20, 2001
41
US
We have attached the SQL server time using the Getdate() function to an application, but we are curious if we can have this displayed in a "ticking" format? Thanks!
 

What exactly do you mean by 'can [we] have this displayed in a "ticking" format?' Terry Broadbent

"The greatest obstacle to discovery is not ignorance -- it is the illusion of knowledge." - Daniel J Boorstin
 
Right now I have the server time displayed on the opening of my application. But, I need to have this time increment. Right now it displays the time upon opening, but stays on that time. Thanks!
 

You'll need to write some code (or find some) in your application language. It is not something you should try do in SQL Server.

What development tool are you using? You may be able to get help with this question in forum for that tool. Terry Broadbent

"The greatest obstacle to discovery is not ignorance -- it is the illusion of knowledge." - Daniel J Boorstin
 
I am using VBA through MSAccess. I also posted in that forum, and have yet to hear anything. thanks for you response!!
 

Here some code you should be able to modify for your needs. It uses the system clock but adjusts the time to match the server time.

Create a label named lblClock on the form.

' create a variable to hold the difference between the server and local PC times
Private TimeInt As Long

Private Sub Form_Activate()
' Set the form time for 1 second
Me.TimerInterval = 1000

' calculate the difference between Server and local PC time
TimeInt = DateDiff("s", Now(), getdateval)

' Initialize the clock
Me!LblClock.Caption = Format(DateAdd("s", TimeInt, Now()), "hh:mm:ss AMPM")
End Sub

Private Sub Form_Timer()
' Set the clock each time the time event fires (1 sec)
Me!LblClock.Caption = Format(DateAdd("s", TimeInt, Now()), "hh:mm:ss AMPM")
End Sub Terry Broadbent

"The greatest obstacle to discovery is not ignorance -- it is the illusion of knowledge." - Daniel J Boorstin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top