20080917T10:20:21000
是台湾一个oracle db中的date字段的值。
在delphi,无法使用datetimetostr等函数转换。
在delphi中,我如何正确读取oracle中该列的值,并转换成正确的datetime类型

解决方案 »

  1.   

    20080917T10:20:21000
    分解一下,应该是
    2008年09月17日10点20分21秒
    因为字符串比较规整,所以你可以采取读取字符串方法进行
    copy(str,1,4)为年
    copy(str,5,2)为月
    copy(str,7,2)为日
    copy(str,10,2)为秒
    copy(str,13,2);为分
    copy(str,16,2);为秒
    下面的事情想你应该知道怎么做了
      

  2.   

    var
        strTemp:string;
        dtTemp:TDateTime;
    begin
        strTemp:='20080917T10:20:21000';
        strTemp:=StringReplace(strTemp,'T',' ',[rfReplaceAll]);
        strTemp:=LeftStr(strTemp,Length(strTemp)-3);
        Insert('-',strTemp,7);
        Insert('-',strTemp,5);
        dtTemp:=StrToDateTime(strTemp);
      

  3.   

    var
        strTemp:string;
        dtTemp:TDateTime;
    begin
        strTemp:='20080917T10:20:21000';
        strTemp:=StringReplace(strTemp,'T',' ',[rfReplaceAll]);
        strTemp:=LeftStr(strTemp,Length(strTemp)-3);
        Insert('-',strTemp,7);
        Insert('-',strTemp,5);
        dtTemp:=StrToDateTime(strTemp);具体问题具体分析
      

  4.   

    这个应该满足楼主需要了
    http://harryfin.spaces.live.com/Blog/cns!31E57C5D97ECDF5!409.entry?wa=wsignin1.0