Date类型怎么么分别得出年月日,结果为三个值

解决方案 »

  1.   

    用 DecodeDate ;
    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;
      

  2.   

    yearOf(now)
    monthOf(now)
    dayOf(now)
      

  3.   

    var  year,month,day:string
     begin
      
      year:= formatDatetime('yyyy',now);
      month:=FormatDateTime('mm',now);
      day:=FormatDateTime('dd',now);
      end
      

  4.   

    var
      yy,mm,dd: dword;
    begin
      decode(now,yy,mm,dd);
      showmessage(inttostr(yy));
      showmessage(inttostr(mm));
      showmessage(inttostr(dd)); 
    end;
      

  5.   

    SQL 语句中用的!
    year(字段)
    month(字段)
    day(字段)