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;

解决方案 »

  1.   

    uses DateUtils;Yearof(date);
    Monthof(date)
      

  2.   

    EXTRACT(YEAR FROM saledate)  从 caledate 取出 年 部分
    EXTRACT(MONTH FROM saledate) 从 caledate 取出 月 部分
    EXTRACT(DAY FROM saledate) 从 caledate 取出 日 部分 
      

  3.   

    另外需要说明的是,delphi5中,要uses DateUtils;
    才可以用yearof/monthof/dayof()
    而在delphi6中则不需要;