DATEDIFF Calculation Where One Argument is NULL
Posted on 2006-03-20
I am trying to write a query where I can calculate the date difference between the date a widget arrived in my facility and the day it shipped. The problem is some widgets have to be repaired before they are shipped. Therefore, some of the widgets have a NULL ship date.
The query so far...
SELECT WidgetModel, datediff(d, max(DockDate), max(ShipDte)) + 4 as SLAInDays
WHERE (DockDate BETWEEN '3/15/2006' AND '3/20/2006') and (shipdte between '3/15/2006' and '3/20/2006')
I need to be able to add an argument in the query for the NULL shipdates, like:
case when isNULL(shipdte, 'GetDate()') or something to that affect.
Any help is greatly appreciated.