--> The trick to take the separate (split) "date", "month" and "years" of the input type TDate. | Delphi Tips Trick

For Newbie

Tuesday, 15 November 2011

The trick to take the separate (split) "date", "month" and "years" of the input type TDate.

| Tuesday, 15 November 2011


Function declaration:
type
   rDate = record
     cdate: Byte;
     cmonth: Byte;
     cyears: Integer;
   end;

function splitdate (Date: TDate): rDate;
var
   date, month, year: Word;
begin
   DecodeDate (date, year, month, date);
   with Result do
   begin
     cdate = date;
     cmonth: = month;
     cyears: = yr;
   end;
end;

Example of implementation:
procedure TForm1.Button1Click (Sender: TObject);
var
   D: rDate;
begin
   D:  splitdate(DateTimePicker1.Date);
   with Memo1.Lines do
   begin
     Clear;
     Add ('Date =' + IntToStr (D.cdate));
     Add ('Month =' + IntToStr (D.cmonth));
     Add ('Year =' + IntToStr (D.cyears));
   end;
end;

Related Posts

No comments: