Query system time from linked server

Posted on 2006-05-17
Last Modified: 2012-06-27
I set up a linked server in my local sql server and my sql like this:

select DATEDIFF(day, T.running_Date, GETDATE()) AS [Cycle time],
FROM   Linkedserver.testdb.dbo.testtable T

running_date is the linked server time, but getdate() function just return my local sql server system time. How can I get linked sql server system time, pls. help!

thanks a lot!

Question by:d_chenxin
    LVL 75

    Accepted Solution

    use openQuery to get the date from the server

    select DATEDIFF(day, T.running_Date, (SELECT ServerDate FROM OPENQUERY(Linkedserver, 'SELECT GETDATE()As ServerDate'))) AS [Cycle time]
    FROM   Linkedserver.testdb.dbo.testtable T

    Author Comment

    Thanks you so much!

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Introduced in Microsoft SQL Server 2005, the Copy Database Wizard ( is useful in copying databases and associated objects between SQL instances; therefore, it is a good migration and upgrade tool…
    Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
    Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
    Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now