Results 1 to 8 of 8

Thread: Date from Server, Not System

  1. #1

    Thread Starter
    Hyperactive Member vbuser1976's Avatar
    Join Date
    Sep 2000
    Location
    Yonkers, NY
    Posts
    404

    Unhappy Date from Server, Not System

    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.
    -vbuser1976
    VB6 Enterprise SP6
    SQL 7.0 SP2
    VBScript, HTML, Javascript, C++, a little UNIX

  2. #2
    New Member
    Join Date
    Apr 2001
    Location
    Birmingham, UK
    Posts
    12

    Lightbulb using winsock?

    This may be a bit of a lame idea, but what about making the server broadcast the time every 10 seconds or so?
    Man who walks through airport turnstiles sideways is going to Bangkok

  3. #3

    Thread Starter
    Hyperactive Member vbuser1976's Avatar
    Join Date
    Sep 2000
    Location
    Yonkers, NY
    Posts
    404

    Arrow Hmm...

    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?
    -vbuser1976
    VB6 Enterprise SP6
    SQL 7.0 SP2
    VBScript, HTML, Javascript, C++, a little UNIX

  4. #4
    New Member
    Join Date
    Apr 2001
    Location
    Birmingham, UK
    Posts
    12

    Talking winsock

    If you have your server running this line of code every 10 seconds:
    Code:
    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:
    Code:
    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!
    Man who walks through airport turnstiles sideways is going to Bangkok

  5. #5

    Thread Starter
    Hyperactive Member vbuser1976's Avatar
    Join Date
    Sep 2000
    Location
    Yonkers, NY
    Posts
    404

    Unhappy What about the date?

    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.
    -vbuser1976
    VB6 Enterprise SP6
    SQL 7.0 SP2
    VBScript, HTML, Javascript, C++, a little UNIX

  6. #6
    Addicted Member
    Join Date
    Mar 2001
    Location
    India
    Posts
    134

    IDEA

    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
    Pavan Kumar

  7. #7

    Thread Starter
    Hyperactive Member vbuser1976's Avatar
    Join Date
    Sep 2000
    Location
    Yonkers, NY
    Posts
    404

    Thanks!

    Thanks clipsie and pavan,

    I will try both of your suggestions. Thanks again.
    -vbuser1976
    VB6 Enterprise SP6
    SQL 7.0 SP2
    VBScript, HTML, Javascript, C++, a little UNIX

  8. #8
    Member
    Join Date
    May 2001
    Location
    Adelaide, Australia
    Posts
    51
    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.
    Matthew Draper
    [email protected]

    "Genius may have its limitations, but stupidity is not thus handicapped." - Elbert Hubbard

    "I like long walks, especially when they are taken by people who annoy me." - Noel Coward

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width