DateTime exitDateTime; if(Convert.IsDBNull(Dr[drvPortfolio["EnterPriceDateTime"])==false) exitDateTime = (DateTime)drvPortfolio["EnterPriceDateTime"]; else // whatever you want to do if IsDbNull returns a trueThere are variations on that syntax, that's the one I've often used