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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Retrieve date/time from server 2

Status
Not open for further replies.

mikey69

Programmer
Jun 23, 2001
303
ZA
I have a distributed application in which there is a log on routine. As part of this routine, I need to have client machines retrieve date and time from the server. They should be able to do it quickly and frequently. The server runs on Windows NT server. Can anyone tell me how to do this?
 
Copied from Help:

This example uses the Now function to return the current system date and time.

Dim Today
Today = Now ' Assign current system date and time.

Msgbox Today

 
He needs the server time. Now() will give him the local time.

Mike69 - there are a million shareware/Freeware program on the Internet to sync your servers and workstations to atomic clocks. Search Google using "Synchronize Internet time Windows NT 4.0" as search criteria and you'll see what I mean. Sync your server and pre-2000 PC's with the Internet time using these programs. On the server, you set it up as a service. In your Access app, shell to the sync program to get the official time, and then call Now() to get your timestamp.

XP and 2000 have functions to sync to the net built in -these are accessed in the Date/Time reset screen in Windows.

As far as some Lan call to get the server time, I don't know of any, but you might try posting the question on a server forum - netware had a way to do this, so I don't know why NT wouldn't.
 
Thanks to both of you. I don't want to go to the internet. Just need to get time from local server. Agree that netware can do it. Just can't find the Windows 2000 analogue.

It has to be there, but where?

Will try a server forum.
 
There is an GetSystemTime API. For an example of how to use it look at
Whether or not it reports the "Server" time I don't know, am at home at the moment so can't test it.

Sorry for my earlier stupidity, not being a Network person, I assumed it standard procedure to Synchronise PC's Date and Time on a Network. Something I will have to watch out for in the future as most of my Programmes incorporate an Audit Trail, one Field being a Time and Date Stamp. Hope you find what you're looking for.
 
BillPower - had a look at that ref. It seems to report local machine time only. For interest, the cause of my problem is users who reset local date to allow them to enter transactions after the event. I haver a really tight logging on routine, which could look at a frozen time on the server, if this is the only way. I did a google search and see that there are many network time servers, but none clearly does what I want. Most seem to synchronise to a carsium clock owned by the US Navy, who are the guardians of time in the USA.

Thanks for your help. When I find the solution, I'll re-post.
 
You could use shell with net time to sync the client time to a server and then use the local time with now()... Although this may not work too well since shell is asynchronous. There is a waitshell in the MSKB.

Any way, the specifics of net time for the command line are
Net Time \\ServerName /set /yes

I use Net Time in the logon script to correct system clock anomolies. I use one of those atomic clock utilities to sync up the server once a day. For your purposes of the malicious user, this will help but the more crafty will still be able to cause havoc. Changing the Regional settings so that the local time is really a far off time comes to mind. Although Net Time may or may not persist the change in region time (something to look into).

If you have access to an SQL server or any ODBC compliant database server, find out how to get the time from it and write an SQL pass through query to obtain the system time.

I hope this helped.
 
Thanks Lameid. Will try it when I visit my customer later this week.
 
How did you solve your time problem? I have the same problem. I have people logging into the program from several different time zones. I would like to the the time from the Windows2000 Server.
 
What Lameid suggesed worked just fine. Simple, really when yuo know how asnd frustrating if you don't. Thanks a million lameid!
 
Thanks LameID, works great, I've added it to the logon scripts so everyone syncs when they logon to the domain.

All I got to do is find out how I can get the server to sync to the internet atomic time and i'm laughing.

Have a star!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top