Reputation: 25
I have two Columns
Move In Date Move Out Date
2/24/2011 2/25/2014
I have similar data for 20,000 rows. I want another column
Length of Stay
(Difference between MoveOutDate
and MoveIn
Date) only in Years.
but I need the query to run for every row in the table.
How can I do this?
Upvotes: 0
Views: 293
Reputation: 28403
Try this
SELECT MoveInDate,MoveOutDate,DATEDIFF(year,MoveInDate,MoveOutDate) As Years
FROM Table1
Upvotes: 1
Reputation: 99
select Move_In_Date,Move_Out_Date,datediff(year,Move_In_Date,Move_Out_Date) as year_diff
from yourTable
Upvotes: 1