I use this code to give the day of the year (ie Feb 10th is the 41st day of the year). It may give you another idea for doing date math.:
function FindDayOfYear(dDate: TDateTime): string;
var
Year, Month, Day: Word;
dTotal, dRounded: double;
begin
DecodeDate(dDate, Year, Month, Day);
dRounded := Round(dDate);
if dRounded < dDate then
dRounded := dRounded + 1;
dTotal := dRounded - EncodeDate(Year,1,1);
Result := FloatToStr(dTotal) + ' ' + IntToStr(Year);
end;