I feel confident this query is written correctly but I am continuing to have "Null" inserted into the expected column. My start and end date columns are datetime and contain date so I am unsure why this is not performing the datediff calculation and updating the column.
Am I doing something wrong that is easily overlooked?
DECLARE @X INT
UPDATE MyTable
SET @X = DATEDIFF(s, Start_Date, End_Date)
,Column1 = CASE
WHEN Start_Date <> NULL
AND End_Date <> NULL
THEN (
SELECT CONVERT(VARCHAR(10), (@x / 86400)) + ' Days ' + CONVERT(VARCHAR(10), ((@x % 86400) / 3600)) + ' Hours ' + CONVERT(VARCHAR(10), (((@x % 86400) % 3600) / 60)) + ' Minutes '
)
ELSE NULL
END
Sample Data: Start Date = 2018-08-08 00:00:00.000 End Date = 2020-08-08 00:00:00.000
(This is the actual data I am using in my real DB)