前者转换没有问题,后者出现异常,请问大家有什么好办法解决吗?

解决方案 »

  1.   

    对了, 
    uses SysUtils;
      

  2.   


    #include <stdio.h>int main()
    {
    int a,b,c;
    sscanf("2008-5-8","%d%*[-/]%d%*[-/]%d",&a,&b,&c);
    printf("%d  %d  %d\n",a,b,c);
    sscanf("2008/5/8","%d%*[-/]%d%*[-/]%d",&a,&b,&c);
    printf("%d  %d  %d\n",a,b,c); return 0;
    }
      

  3.   

    procedure TForm1.Button1Click(Sender: TObject);
    var d:TDateTime;
        tmp:char;
    begin
     tmp :=DateSeparator;
     DateSeparator :='/';
     d :=  StrToDate('2007/12/31');
     ShowMessage(DateToStr(d));
     DateSeparator := tmp;
    end;
      

  4.   

    先把 2008/5/8   中的  / replace 成 -Replaces all occurrences of a substring with another string.UnitStrUtilsCategorystring handling routinesDelphi syntax:function AnsiReplaceStr(const AText, AFromText, AToText: string): string;C++ syntax:extern PACKAGE AnsiString __fastcall AnsiReplaceStr(const AnsiString AText, const AnsiString
     AFromText, const AnsiString AToText);DescriptionCall AnsiReplaceStr to scan the string specified by AText and replace all occurrences of the string specified by AFromText with the string specified by AToText. Occurrences of AFromText are identified by a case-sensitive comparison. The identification of substrings is not recursive: if the substitution of AToText results in a new match for AFromText, that match is not replaced.
      

  5.   


    设置日期分割符,DateSeparator:='/';