Query system time from linked server

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!

Who is Participating?
Aneesh RetnakaranConnect With a Mentor Database AdministratorCommented:
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
d_chenxinAuthor Commented:
Thanks you so much!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.