skip to Main Content

I have SQL Server installed on a Centos. I set the server date and time to my local date time and it is OK. But when I run getdate() in SQL Server it gives date and time based in the US time zone. I know I can get the date and with offset options but I need get the local date and time just with getdate().

How can I force SQL Server to get date and time from the operating system (Centos)?

2

Answers


  1. Chosen as BEST ANSWER

    I reinstall the sqlserver after setting the operating timezone and solved the problem.


  2. Try install tzdata :

    yum install tzdata
    

    set correct timezone:

    rm /etc/localtime 
    
    cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
    
    TZ="Asia/Shanghai"
    

    then run tzselect choose correct timezone:

    tzselect
    

    finally, restart mssql:

    sudo systemctl restart mssql-serer
    

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search