• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 310
  • Last Modified:

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!

Sidney
0
d_chenxin
Asked:
d_chenxin
1 Solution
 
Aneesh RetnakaranDatabase 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
0
 
d_chenxinAuthor Commented:
Thanks you so much!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now