| |
|
If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
|
 |

03-23-04, 20:53
|
|
Registered User
|
|
Join Date: Mar 2004
Posts: 36
|
|
Synchronize Server Time
|
|
Hi all the experts i have the problem in synchronize the server time with my client workstation! Because my application i wrote, all the date and time must get from the server time.
So can somebody show my how to get the server time and set the server time to local time.
|
|

03-24-04, 09:46
|
|
Resident Curmudgeon
|
|
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,606
|
|
What OS / Database Engine does the server run? What OS / programming language does the client run?
-PatP
|
|

03-24-04, 20:16
|
|
Registered User
|
|
Join Date: Mar 2004
Posts: 36
|
|
|
|
Quote:
Originally posted by Pat Phelan
What OS / Database Engine does the server run? What OS / programming language does the client run?
-PatP
|
Server is Windows 2000 Server Family
and the client is Win9x to WinXp
|
|

03-24-04, 21:21
|
|
Resident Curmudgeon
|
|
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,606
|
|
Ok, getting the server time is easy. Just use:
Code:
SELECT GetDate(), GetUTCDate()
and it will return a single row with one column with the current local server datetime, and another with the corresponding UTC datetime.
How you set that on the client varies a great deal, but you can use the Windows API call to SetSystemTime if nothing easier is available.
One option for you to consider that I would strongly recommend is to build all of the time sensitive logic into server side components (stored procedures, DCOM DLLs, or .NET assemblies). This allows you to make changes to the time sensitive code easily on the server instead of having to track down every blasted machine running a copy of your application.
-PatP
|
|

03-25-04, 01:17
|
|
Registered User
|
|
Join Date: Mar 2004
Posts: 36
|
|
Quote:
Originally posted by Pat Phelan
Ok, getting the server time is easy. Just use:
Code:
SELECT GetDate(), GetUTCDate()
and it will return a single row with one column with the current local server datetime, and another with the corresponding UTC datetime.
How you set that on the client varies a great deal, but you can use the Windows API call to SetSystemTime if nothing easier is available.
One option for you to consider that I would strongly recommend is to build all of the time sensitive logic into server side components (stored procedures, DCOM DLLs, or .NET assemblies). This allows you to make changes to the time sensitive code easily on the server instead of having to track down every blasted machine running a copy of your application.
-PatP
|
PatP the server i have i only the Domain Server and does not have any running database attach to it. So i cannot use your matter already.
|
|

03-25-04, 07:34
|
|
Resident Curmudgeon
|
|
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,606
|
|
Ok, can you issue a command (possibly via a batch file)? If so, you could use:
Code:
NET TIME [\\computer] [/SET] [/YES]
So, if your common timesource was named tick, you could use:
Code:
NET TIME \\tick /SET /YES
to make the current computer's time match the time on the tick server.
-PatP
|
|

03-25-04, 20:15
|
|
Registered User
|
|
Join Date: Mar 2004
Posts: 36
|
|
Quote:
Originally posted by Pat Phelan
Ok, can you issue a command (possibly via a batch file)? If so, you could use:
Code:
NET TIME [\\computer] [/SET] [/YES]
So, if your common timesource was named tick, you could use:
Code:
NET TIME \\tick /SET /YES
to make the current computer's time match the time on the tick server.
-PatP
|
PatP i have tried this method before, but after i run the batch file, the dos prompt screen still maintain and cannot close automatically.
|
|

03-25-04, 21:13
|
|
Resident Curmudgeon
|
|
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,606
|
|
What programming language are you using? For example in VB you could use the Shell() function to run the NET command.
-PatP
|
|

03-26-04, 01:35
|
|
Registered User
|
|
Join Date: Mar 2004
Posts: 36
|
|
Quote:
Originally posted by Pat Phelan
What programming language are you using? For example in VB you could use the Shell() function to run the NET command.
-PatP
|
Delphi 5
|
|

03-26-04, 08:53
|
|
Resident Curmudgeon
|
|
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,606
|
|
I'd run the NET command using Delphi's ShellAPI to avoid the complications of batch files, etc.
-PatP
|
|

03-28-04, 20:15
|
|
Registered User
|
|
Join Date: Mar 2004
Posts: 36
|
|
Quote:
Originally posted by Pat Phelan
I'd run the NET command using Delphi's ShellAPI to avoid the complications of batch files, etc.
-PatP
|
I tried the WinExec on Delphi ShellAPI, but when run that command, the command prompt screen come out and cannot disappear
|
|

03-28-04, 21:45
|
|
Resident Curmudgeon
|
|
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,606
|
|
It shows the window even when you supply the SW_HIDE value ?!?!
That smells like a bug to me! Are you using the current service packs for Delphi 5? I haven't kept track of the changes that were made that long ago, but I suspect that you might have found a problem that was fixed in a service pack.
-PatP
|
|

03-29-04, 04:47
|
|
Registered User
|
|
Join Date: Mar 2004
Posts: 36
|
|
Quote:
Originally posted by Pat Phelan
It shows the window even when you supply the SW_HIDE value ?!?!
That smells like a bug to me! Are you using the current service packs for Delphi 5? I haven't kept track of the changes that were made that long ago, but I suspect that you might have found a problem that was fixed in a service pack.
-PatP
|
Hi PatP,
this solve my problem already, thank you very much!!!!
|
|

03-29-04, 08:17
|
|
Resident Curmudgeon
|
|
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,606
|
|
Oh, you just gotta love it when a plan comes together! I'm glad that we've finally managed to beat this problem into submission for you!
-PatP
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|