听小白兔的看看吧!
先看看showmessage(datetimetostr(now));
他将显示当前的日期格式!

解决方案 »

  1.   

    同意whitehare(小白免) 的观点,检查检查,可能设成两位年份了等。
      

  2.   

    我使用strtodatetime(str1); 让str1='2002-09-03 09:12:13' 没有出错
    str1应写成你机器的日期格式,长日期格式或短日期格式如果想字符串固定格式但与机器设定无关可用:
    var Temy,Temm,Temd:integer;Newdate:TDate;DateString:String;
    begin
    DateString:='2002/01/18'
    Temy:=strtoint(copy(DateString,1,4));
    temm:=strtoint(copy(DateString,6,2));
    temd:=strtoint(Copy(DateString,9,2));
    Newdate:=EncodeDate(Temy,Temm,Temd);
    //Ddate为转换后的日期,一定要保证DateString的格式正确,时间你自己加上吧
    end;