我要将时间转换为DateTime,字符串均为yyyy-mm-dd hh:nn:ss的格式,即如:2001-01-01 11:00:00 我使用StrToDateTime转换,在转换的过程中,有时出现错误,有时又不出现,请高手指教! 注:在程序中存在着上千万次地将日期转换为时间
我是这样做的:var
dt:TDateTime;
begin
dt := StrToDateTime('2001-01-01 11:00:00');
end; 在程序运行很长时间,即这样的转换上万次后,可能出现错误:2001-01-01 11:00:00 is not a valid date and time在代码中加入如下代码,即:
var
dt:TDateTime;
begin
//加入的代码========================
DateSeparator := '-';
ShortDateFormat := 'yyyy-mm-dd';
LongDateFormat := 'yyyy-mm-dd';
TimeSeparator := ':';
ShortTimeFormat := 'hh:nn:ss';
LongTimeFormat := 'hh:nn:ss';
//==================================== dt := StrToDateTime('2001-01-01 11:00:00');
end; 在程序运行很长时间后也会出现上述错误我的程序原理如下:
启动DCOM服务,Client在不同的时间自动启动一个/多个线程调用服务端同一方法,线程运行完后退出.
我是这样做的:var
dt:TDateTime;
begin
dt := StrToDateTime('2001-01-01 11:00:00');
end; 在程序运行很长时间,即这样的转换上万次后,可能出现错误:2001-01-01 11:00:00 is not a valid date and time在代码中加入如下代码,即:
var
dt:TDateTime;
begin
//加入的代码========================
DateSeparator := '-';
ShortDateFormat := 'yyyy-mm-dd';
LongDateFormat := 'yyyy-mm-dd';
TimeSeparator := ':';
ShortTimeFormat := 'hh:nn:ss';
LongTimeFormat := 'hh:nn:ss';
//==================================== dt := StrToDateTime('2001-01-01 11:00:00');
end; 在程序运行很长时间后也会出现上述错误我的程序原理如下:
启动DCOM服务,Client在不同的时间自动启动一个/多个线程调用服务端同一方法,线程运行完后退出.
ShortDateFormat := 'yyyy-mm-dd';
LongDateFormat := 'yyyy-mm-dd';
TimeSeparator := ':';
ShortTimeFormat := 'hh:nn:ss';
LongTimeFormat := 'hh:nn:ss';
TO:sunspeedzy(子秦) 不需写到数据库
转换很多次后就错了!不知是为什么