Reputation: 205
I want to update a column of a table with the value coming from the following query. SELECT DATEDIFF(days,'EndDate','StartDate') AS DiffDate. Can I do this in a single sql statement? Right now I have a table with columns(StartDate, EndDate, DiffDate) with values for StartDate and EndDate but not for DiffDate. DiffDate is null now. I am trying to update the value of DiffDate from null to the Date Difference. I appreciate the help. Thank you.
Upvotes: 0
Views: 1083
Reputation: 26406
update TheNameOfYourTable
set DiffDate = DATEDIFF(days, EndDate, StartDate)
Upvotes: 2