Results 1 to 6 of 6

Thread: [RESOLVED] select server date

  1. #1

    Thread Starter
    Hyperactive Member yousufkhan's Avatar
    Join Date
    Jan 2002
    Location
    India
    Posts
    492

    Resolved [RESOLVED] select server date

    somebody has shown like this to capture the server date
    is it ok to have server date like this

    rsdate as adodb.recordset
    Set rsdate = conn.Execute("select getdate()")
    Last edited by yousufkhan; Sep 21st, 2007 at 06:27 AM.

  2. #2
    Fanatic Member kaffenils's Avatar
    Join Date
    Apr 2004
    Location
    Norway
    Posts
    946

    Re: select server date

    I'm not slzamany, but I'll answer anyway.

    Kaffenils: "Yes."

  3. #3
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: select server date

    To expand on that a little, it is fine for SQL Server.

    Based on another thread of yours, I think it is important to remind you that it will not work for Access - and there is nothing in terms of SQL that will do it (you need to use VB code to find the date/time of another machine, and you can probably find it in our CodeBank forums).

  4. #4
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: select server date

    I'm not kaffenils

    But I would do:

    Code:
    rsdate as adodb.recordset
    Set rsdate = conn.Execute("select Convert(varchar(23),getdate(),121)")
    to get it in a consistent format - that full GETDATE() datetime with milliseconds...

    Did you want it with time??

    Otherwise you do:

    Code:
    rsdate as adodb.recordset
    Set rsdate = conn.Execute("select Convert(varchar(10),getdate(),101)")
    That returns MM/DD/YYYY

    ...but from what Si said - is this ACCESS???

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  5. #5

    Thread Starter
    Hyperactive Member yousufkhan's Avatar
    Join Date
    Jan 2002
    Location
    India
    Posts
    492

    Re: select server date

    szlamany

    actualy when i posted this thread i had specified your name in that to answer thats y kaffenils has written like that i am not szlamany but is ll answer so you pls dont mind it

    now the problems is that i m helpless with access database bcoz one of my application is running since a long and i am not in the position to change that database to sql and problem i m facing is that if client machines date gets change due to any reason than transaction are taking wrong date thats y
    i wanted to use server date while inserting or updating the records in access mdb even if is use default date it ll insert the local machine date but if i select the server date capture as us said

    rsdate as adodb.recordset
    Set rsdate = conn.Execute("select Convert(varchar(10),getdate(),101)")

    than i ll get the correct running date bcoz the access mdb is also on the same serve where the sql is
    friends now tell me what is your advise

  6. #6
    Fanatic Member kaffenils's Avatar
    Join Date
    Apr 2004
    Location
    Norway
    Posts
    946

    Re: select server date

    Quote Originally Posted by szlamany
    But I would do:

    Code:
    rsdate as adodb.recordset
    Set rsdate = conn.Execute("select Convert(varchar(23),getdate(),121)")
    to get it in a consistent format
    I always do let the client take care of the formatting.

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