You did not specify the unit of measure for the count. I used MINUTE in the example below. Using DATEDIFF, you can also specify other units of measure. See
DATEDIFF (Transact-SQL)[
^]
SELECT ItemId,ISNULL(AssignmentName,"") As AssignmentName,DATEDIFF(MINUTE,ISNULL(opendate,GETDATE()),ISNULL(closedate,GETDATE())) AS Minutes_Elapsed FROM testdates;
Using constants to test, the result was
90.
SELECT DATEDIFF(minute,ISNULL('2012-01-01 08:00:00',GETDATE()),ISNULL('2012-01-01 09:30:00',GETDATE())) As Minutes_Elapsed