tags:

views:

96

answers:

2

hi.. i have a combobox that show the month from jan till dec where the user can choose which month they want to view the data..this is for the 1st data..

for i := iYear - 2 to iYear + 1 do begin 
for j := 1 to 12 do begin   
  dTem := EncodeDate(i, j, 1);  
  sTem := FormatDateTime('mmm yyyy', dTem);  
  cboMonth.Items.Add(sTem);  
end;  

end;

dFromDate := EncodeDate(iYr, iMon, 1);
dToDate   := EncodeDate(iYr, iMon, DaysInMonth(iYr, iMon));

My problem is i also want to show the data for the year..when the user choose the month from the combobox then automatically my data will display the data from 6 month before untill the month that they choose from the combobox..

+5  A: 

Check out IncMonth.

Will A
A: 

exactly

dToDate := incmonth(dFromDate, -6);// -6 = Less 6 months