菜鸟问题~~ 问一下怎样给Edit.text赋予现在时间的年份或者月份或者日期怎样获得现在时间是星期几(星期一、二...)

解决方案 »

  1.   

    Edit.text:=DateToStr(Date: TDateTime);
    WeekOf(const AValue: TDateTime)
      

  2.   

    Edit.text:=DateToStr(Date: TDateTime);那我只需要年份?或者月份 那该怎么办呢?
      

  3.   

    var
       YY,MM,s:string;
    begin
    s:=DateToStr(date );
    YY:=copy(s,1,4);
    MM:=copy(s,6,2);
    if MM[2]='-' then MM[2]:=chr(0);edit1.Text:=‘Year='+YY+' Month='+MM;
    end;
      

  4.   

    这种方法是不是麻烦了一点?我是想问问如何使用Day\Month\Year函数转换成字符串赋知到Edit.text?
    这种方法可不可以呢?如果可以,该怎么实现?
      

  5.   

    uses DateUtils
    Edit1.Text:=floattostr(YearOf(const AValue: TDateTime)); 
    .....
    DayOf(const AValue: TDateTime);
    MonthOf(const AValue: TDateTime)
      

  6.   

    var
       YY,MM,s:string;
    begin
    s:=DateToStr(date );
    YY:=copy(s,1,4);
    MM:=copy(s,6,2);
    if MM[2]='-' then MM[2]:=chr(0);edit1.Text:=‘Year='+YY+' Month='+MM;
    end;