var yy,mm,dd:word begin DecodeDate(DateTimePicker.date,yy,mm,dd); label1.caption:=inttostr(yy); label2.caption:=inttostr(mm); label3.caption:=inttostr(dd); end;
var yy,mm,dd:word begin DecodeDate(DateTimePicker.date,yy,mm,dd); label1.caption:=inttostr(yy); label2.caption:=inttostr(mm); label3.caption:=inttostr(dd); end;
lbMonth.text:=Copy(DateTimePicker1.text,7,2);
lbDay.text:=Copy(DateTimePicker1.text,11,4);
procedure DecodeDate(Date: TDateTime; var Year, Month, Day: Word);
lbmonth.text:=format('mm',datetimepicker1.date);
lbday.text:=format('dd',datetimepicker1.date);
lbMonth.text:=FormatDateTime('m',DateTimePicker1.DateTime);
lbDay.text:=FormatDateTime('d',DateTimePicker1.DateTime);
begin
Label1.caption:=FormatDateTime('yyyy',DateTimePicker1.date);
Label2.caption:=FormatDateTime('mm',DateTimePicker1.date);
Label3.caption:=FormatDateTime('dd',DateTimePicker1.date);
end;
DecodeTime(Now,hour,minu,Sec,MSec);
begin
DecodeDate(DateTimePicker.date,yy,mm,dd);
label1.caption:=inttostr(yy);
label2.caption:=inttostr(mm);
label3.caption:=inttostr(dd);
end;
当然用FORMATDATETIME也可以的,看你自己了,DELPHI的帮助上都有的
begin
DecodeDate(DateTimePicker.date,yy,mm,dd);
label1.caption:=inttostr(yy);
label2.caption:=inttostr(mm);
label3.caption:=inttostr(dd);
end;
label2.caption:=inttostr(monthof(DateTimePicker1.date));
label3.caption:=inttostr(dayof(DateTimePicker1.date));
pst : TSystemTime;SendMessage(DateTimePicker1.Handle, $1001, 0, Longint(@pst));
Label1.caption := inttoStr(pst.wyear);
label2.caption := IntToStr(pst.wMonth);
label3.caption := IntToStr(pst.wday);