Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
251 views
in Technique[技术] by (71.8m points)

sql - how can i calculate between 2 date count of solution time in MSSQL

SELECT* from ticketOperations  
--this is operations table
INNER JOIN tickets ON tickets.ID = ticketOperations.ticketID, 
--they connect with foreign key
DATEDIFF(DAY,tickets.date, ticketOperations.closingDate) AS SOLUTIONTIME  
--this is calculatefunction 
WHERE tickets.ticketType=0 
--tickettype

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You are facing issue as you are using DATEDIFF in ON clause without any expression or condition.

Msg 208, Level 16, State 1, Line 6 Invalid object name 'DATEDIFF'. that's my error string

If you want to know the difference in date then use it in the SELECT clause.

SELECT tickets.*, ticketOperations.*,
       DATEDIFF(DAY,tickets.date, ticketOperations.closingDate) AS SOLUTIONTIME  
  from ticketOperations  
 INNER JOIN tickets ON tickets.ID = ticketOperations.ticketID, 
 WHERE tickets.ticketType=0 

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...