SysUtils
procedure DecodeData(Date: TDateTime; var Year, Month, Day: Word);
DecodeDate打断TdateTime成为年月日的值。
DecodeDate打断由Date参数说明的值成为年月日的值。
如果TDateTime值是小于或等于0,那么返回的年月日值为0;
这个例子使用一个按纽和两个标签,当按击按钮时,当前的日期和时间就会出现在两个标签的标题中显示。
procedure TForm1.Button1Click(Sender: TObject);
var
Present: TDateTime;
Year, Month, Day, Hour, Min, Sec, MSec: Word;
begin
Present := Now;
DecodeDate(Present, Year, Hour, Day);
Label1.Caption := 'Today is Day ' + IntToStr(Day) + ' of Month '+ IntToStr(Month) + ' of Year ' + IntToStr(Year);
DecodeTime()Present, Hour, Min, Sec, MSec);
Label2.Caption := 'The time is Minute ' + IntToStr(Min) + ' of Hour '+ IntToStr(Hour);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
Present: TDateTime;
Year, Month, Day, Hour, Min, Sec, MSec: Word;
begin
Present:= Now;
DecodeDate(Present, Year, Month, Day);
Label1.Caption := 'Today is Day ' + IntToStr(Day) + ' of Month '
+ IntToStr(Month) + ' of Year ' + IntToStr(Year);
DecodeTime(Present, Hour, Min, Sec, MSec);
Label2.Caption := 'The time is Minute ' + IntToStr(Min) + ' of Hour '
+ IntToStr(Hour);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
MyDate: TDateTime;
begin
MyDate := EncodeDate(StrToInt(Edit1.Text), StrToInt(Edit2.Text), StrToInt(Edit3.Text));
Label1.Caption := DateToStr(MyDate);
end;
请发表评论