Added check for is null around datetime.