PDA

Click to See Complete Forum and Search --> : Date from Server, Not System


vbuser1976
Apr 30th, 2001, 10:52 AM
Hi!

Does anyone have an API function or some other code, that instead of getting the date of the system that is asking for it in my app, to get the date of the server where the data is held (i.e. my SQL server)?

Any suggestions/comments would be greatly appreciated.

clipsie
Apr 30th, 2001, 01:35 PM
This may be a bit of a lame idea, but what about making the server broadcast the time every 10 seconds or so?

vbuser1976
Apr 30th, 2001, 01:39 PM
Thanks for your reply.

How do I do that(what would broadcasting it do?)? Any sample code would be appreciated. Also, would I be able to save that date in a database table?

clipsie
Apr 30th, 2001, 01:58 PM
If you have your server running this line of code every 10 seconds:
winsock1.protocol = UDPprotocol or whatever it is, I can't remember what it is but there are only two options, pick the UDPish one
winsock1.remotehost "255.255.255.255"
winsock1.senddata time$
and, on your client, under winsock1_dataarrival event:
winsock1.getdata timein, vbstring
and then the time, which is updated every 10 seconds, is stored in the variable timein, so that should give you a 10 second accuracy of the time. If you want you can increment the timein every 10 seconds so that you have the time to an accuracy of 1 second from the server.

Let me know what you think!

vbuser1976
Apr 30th, 2001, 02:02 PM
Is this the same for the date? That is what I am really looking for. Also, is there a need for me to add a specific component/reference, if so, what is it?

Thanks again for all your help.

pavan
May 1st, 2001, 01:46 AM
Why dont u try passing a SQL query to ur SQL server to retrieve the Date/Time from the server. There might be a discrepency of 1 or 2 secs. but u can get the date and time.

try using the select statement

select sysdate from dual; ( This code is for ORACLE i really dont remember what it will be for SQL server)

But i think this should work.


Let me know ur views about this

vbuser1976
May 1st, 2001, 07:20 AM
Thanks clipsie and pavan,

I will try both of your suggestions. Thanks again.:D

Matthew Draper
May 1st, 2001, 09:35 AM
For SQL server, I believe the command would be:
"SELECT now() AS ServerDateTime FROM <InsertSomeTableNameHere> LIMIT 1"

I think you have to specify a valid table though. And the AS is a vague recollection... there's a command like that, anyway.

Sorry I can't be of more specific assistance.