Try something like this... subsituting your own table / field names, of course...
PARAMETERS [Start Date?] DateTime, [End Date?] DateTime;
SELECT mytable.ContractStart, mytable.ContractEnd, DateDiff('d',IIf([ContractStart]>[Start Date?],[ContractStart],[Start Date?]),IIf([ContractEnd]>[End...