Hi. Can someone assist a newbie in calculating the length of time (in days) from one date value to another?
For example, I have START_DATE and END_DATE values (both DATETIME datatypes) in a temp table. I want to update the table with a DURATION value. I tried the following:
UPDATE #TEMP1
SET DURATION = (END_DATE - START_DATE)
FROM #TEMP1
WHERE END_DATE IS NOT NULL
However, I'm getting error "Invalid operator for datatype op: SUBTRACT type: DATETIME." I've tried converting the datatype without much luck either.
Much appreciate the feedback.
For example, I have START_DATE and END_DATE values (both DATETIME datatypes) in a temp table. I want to update the table with a DURATION value. I tried the following:
UPDATE #TEMP1
SET DURATION = (END_DATE - START_DATE)
FROM #TEMP1
WHERE END_DATE IS NOT NULL
However, I'm getting error "Invalid operator for datatype op: SUBTRACT type: DATETIME." I've tried converting the datatype without much luck either.
Much appreciate the feedback.