Change SQL Time

  • Hello,

    I've searched alot for this info but the only thing I can find is how to change the default Language for the users.

    What happens is that I have Microsoft SQL Server Enterprise Edition - 9.00.3042.00 (Intel X86) Feb 9 2007 22:47:07 installed on a Windows Server 2003 Enterprise Edition. Nothing fancy here, except that the time in SQL and Windows is not the same. In SQL I see 10:00AM and in Windows it will be 05:00PM.

    Is there a way to change this without a new SQL installation?

    I've used the T-SQL code:

    select getdate() [Current Datetime]

    Thank you for your time.

  • jjssilva (10/9/2008)


    Hello,

    I've searched alot for this info but the only thing I can find is how to change the default Language for the users.

    What happens is that I have Microsoft SQL Server Enterprise Edition - 9.00.3042.00 (Intel X86) Feb 9 2007 22:47:07 installed on a Windows Server 2003 Enterprise Edition. Nothing fancy here, except that the time in SQL and Windows is not the same. In SQL I see 10:00AM and in Windows it will be 05:00PM.

    Is there a way to change this without a new SQL installation?

    I've used the T-SQL code:

    select getdate() [Current Datetime]

    Thank you for your time.

    SQL Server doesn’t keep its own time, it takes the time from the OS. Maybe you are comparing the results of select getdate() to the time on your workstation and not to the time on the server it self.

    Adi

    --------------------------------------------------------------
    To know how to ask questions and increase the chances of getting asnwers:
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    For better answers on performance questions, click on the following...
    http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

  • Adi,

    I'm comparing the time between this SQL Installation and all the servers in the Domain. This SQL Instance is the only one with this time difference. All the others have the correct time.

  • jjssilva (10/9/2008)


    Adi,

    I'm comparing the time between this SQL Installation and all the servers in the Domain. This SQL Instance is the only one with this time difference. All the others have the correct time.

    You should check why the OS on that server has the wrong time. As I wrote before SQL Server gets the time from the OS. The reason that this instance of SQL Server shows a different time then other instances is that the OS on this instance has the wrong time. Reinstalling this instance of SQL Server will not help at all.

    --------------------------------------------------------------
    To know how to ask questions and increase the chances of getting asnwers:
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    For better answers on performance questions, click on the following...
    http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

  • Adi is correct, SQL Server, and all applications get their time from the OS of the machine where it is installed. If you are on your workstation with SSMS and query the server, it's the server time, not your workstation time.

    Check the server.

  • Hello,

    I did check the server and confirmed that the time is is correct with all the other machines, but SQL still has that time difference.

    I'm clueless here. I've checked the Regional Settings and there are other servers with the same settings and don't have this time difference issue.

  • jjssilva (10/10/2008)


    I'm clueless here.

    the date and time shown above is 10PM not AM (22:47).

    what you are seeing is the installed date and time i believe

    -----------------------------------------------------------------------------------------------------------

    "Ya can't make an omelette without breaking just a few eggs" 😉

  • No Perry.

    One thing is the SQL version we have installed, another is the time that the T-SQL statement is giving me and the other is the time show in the Windows server itself.

    My problem is between the SQL and Windows Time.

  • jjssilva (10/10/2008)


    Hello,

    I did check the server and confirmed that the time is is correct with all the other machines, but SQL still has that time difference.

    I'm clueless here. I've checked the Regional Settings and there are other servers with the same settings and don't have this time difference issue.

    Why did you check regional settings? Why are you comparing the time that you get with select getdate() with other servers instead of comparing it to the specific server’s OS time?

    Connect to the server (locally or with RDP). Make sure that this is the server that the SQL Server is installed on. See the time at the OS level (If you don’t know how to see it, and there isn’t a clock on the task bar, just open a DOS window and type the command Time). Then open SQL Server management studio on the same server. Then issue a select getdate() statement and see if it shows the same time as you saw when you checked on the OS level. Make sure that your are using getdate() function and not getutcdate function. If it is not the same, try opening a call in Microsoft. As I wrote before SQL Server gets the time from the OS and doesn’t keep its own version of the time.

    Adi

    --------------------------------------------------------------
    To know how to ask questions and increase the chances of getting asnwers:
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    For better answers on performance questions, click on the following...
    http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

  • I checked all the other servers including the Database server because they are all on the same Domain, this means these servers are synchronized.

    I already had check the Time on the Database server and checked the SQL as well.

  • Have to agree with the others. I can't even get SQL Server to show a time different than the server installed on.

    I think something is missing from your description of the problem. How are you connecting to the server to check the time using SQL?

    😎

  • Database Server A is the server with SQL installed. In order to connect to this Instance I need to go to a Terminal Server B because Database Server A does not have SQL Manager installed.

    Both these servers are in time sync, all have the same time.

    From Terminal Server B I can also connect to Database Servers C and D to get the time. All read the time correctly.

    The only Time difference in all the servers is from the SQL Instance installed on Database Server A.

  • Take a look at the server's time zone setting.

    Is it correct?

  • Michael F. McCulloch (10/10/2008)


    Take a look at the server's time zone setting.

    Is it correct?

    Yes it is.

    I've doubled checked everything. Including the default Language.

    There's nothing in the server different from all the others servers with SQL.

    It's seems I'm down to reinstall the Instance that have the wrong time. Any other ideas?

    Thanks!

  • Please run the following and see what you get.

    SELECT getdate()

    EXEC master..xp_cmdshell 'DATE /T'

    EXEC master..xp_cmdshell 'TIME /T'

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 15 posts - 1 through 15 (of 21 total)

You must be logged in to reply to this topic. Login to reply