Board index » delphi » How to get Birth Dates
Peet Koekemoer
![]() Delphi Developer |
How to get Birth Dates2005-05-15 04:19:47 PM delphi60 Hi All, I'm using D7, ADO, and MS SQL2000 I created an app that stores the employees information. (Name, Surname, Race, Gender, BirthDate, etc.) I now have to create a Birthdate report to show all the employees who's birthdates falls within as specific period. Now the problem that I have is the employee's original birthdate was 11-April-1976 and now we are in 2005, but I want to see all the employees who's birthdates falls between 01-April-2005 and 30-April-2005. How do I Ignore the year. Below is my Procedure that I have so far: procedure TBirthDatesReportForm.LoadData; Var FromDate, ToDate : TDate; begin //Load all the data into the grid Grid.RowCount := 2; Grid.ClearRows(1,1); //Ok Now get the data With DataModuleForm.ADOQuery do begin FromDate := Trunc(FromDateBox.Date); ToDate := Trunc(ToDateBo.Date); SQL.Clear; SQL.Add('Select Operation, Current_Department, IndustryNo, Name,'); SQL.Add('Surname, Initials, Designation, BirthDate'); SQL.Add('from EmployeeView'); SQL.Add('Where BirthDate>= :FromDate and BirthDate <= :ToDate'); Parameters.ParamValues['FromDate'] := FromDate; Parameters.ParamValues['ToDate'] := ToDate; DisableControls; Open; if IsEmpty = False then begin While NOT EOF do begin Grid.Cells[0,Grid.RowCount-1] := FieldByName('Operation').AsString; Grid.Cells[1,Grid.RowCount-1] := FieldByName('Current_Department').AsString; Grid.Cells[2,Grid.RowCount-1] := FieldByName('IndustryNo').AsString; Grid.Cells[3,Grid.RowCount-1] := FieldByName('Name').AsString; Grid.Cells[4,Grid.RowCount-1] := FieldByName('Surname').AsString; Grid.Cells[5,Grid.RowCount-1] := FieldByName('Initials').AsString; Grid.Cells[6,Grid.RowCount-1] := FieldByName('Designation').AsString; Grid.Cells[7,Grid.RowCount-1] := FormatDateTime('dd-MMM',FieldByName('BirthDate').AsDateTime); Grid.RowCount := Grid.RowCount+1; Grid.ClearRows(Grid.RowCount-1,1); Next; end; //Ok remove the last row as it is empty Grid.RowCount := Grid.RowCount-1; end; Close; EnableControls; end; Thanx, Peet |