我写了一个函数function convert(date:string):string;
var
i:integer;
resu:string;
begin
if trim(date)<>'' then
begin
resu:=copy(date,0,4);
resu:=resu+'-';
resu:=resu+copy(date,6,2);
resu:=resu+'-';
resu:=resu+copy(date,9,2);
result:=resu;
end;
end;你每次可以先调用一下这个函数,下面是调用示例:
procedure TForm1.Button1Click(Sender: TObject);
begin
showmessage(convert('2002.03.06'));
end;传出来的是类似2002-03-06的字符串,然后就好办了
你也可以在sql里面用date函数来比较两个字符型的日期的大小
var
i:integer;
resu:string;
begin
if trim(date)<>'' then
begin
resu:=copy(date,0,4);
resu:=resu+'-';
resu:=resu+copy(date,6,2);
resu:=resu+'-';
resu:=resu+copy(date,9,2);
result:=resu;
end;
end;你每次可以先调用一下这个函数,下面是调用示例:
procedure TForm1.Button1Click(Sender: TObject);
begin
showmessage(convert('2002.03.06'));
end;传出来的是类似2002-03-06的字符串,然后就好办了
你也可以在sql里面用date函数来比较两个字符型的日期的大小
解决方案 »
- 执行插入操作的时候如何把字段''值改成null值
- 求 sql语句 如何判断两个edit的内容都与数据表的对应字段记录相符?
- listview中显示俩个字段的问题
- 别问我爱你有多深
- 键盘在delphi的值
- 各位,谁知道哪里有delphi7的升级包
- 如何让我 按下'回车键'时候,执行某个程序??????
- 有哪伟兄台对ExpressQuantumGrip比较熟悉的,在下有个问题!ExpressQuantumGrid是否支持中文?
- 在Delphi中如何调用.chm帮助文件?
- 用什么发短信比较稳定呢????
- 我找到一个可以将Html文件编译成EXE文件的工具,我把我的网站都编译成一个EXE了。
- 这个错误提示怎么解决?
dd: string;
begin
{dd将以“2002.05.10”的格式显示,具体格式可以改变}
DateTimeToString(dd,'yyyy.mm.dd',Date);//yyyy.mm.dd为显示格式
end;
还可以用Format改变
function Convert(S:String):TDate;
begin
while Pos('.',S)<> 0 do
S[Pos('.',S)]:='-';
Result:=StrToDate(S);
end;
S为从VFP表中得到的时间串,然后转化成日期变量。不过从VFP中得出的串一定要正确时间格式(符合VFP表的标准)
与当前时间比较可以这样完成:
var
DateStr:String;
TempDate:TDate;
begin
DateStr:=Table1.FieldByName('日期字段').AsString;
TempDate:=Convert(DateStr);
if Date>TempDate then//当前时间大于表内时间
……
else//当前时间不大于表内时间
……
end;
2 不要你索引
3 多次判断 字符是数字 格式如何