水晶报表中的语句语法错误--进来看看
有一个老的.rpt文件,里面有一个formula field,是将一个SQL中的datatime字段以"8/3/2002 03:47:11"这种形式显示在报表上。check formula text 没有错误,我现在在另一个新报表文件上想添加一个相同的formula,却报错,怎么回事?
代码如下:
StringVar dt:={Viewlog.viewlog_date_time};
'-->此处,等号后面报错:A string is required here
if dt[6 to 6]<>"0" and dt[9 to 9]<>"0" then dt:=dt[6 to 8]+dt[9 to 10]+"/"+dt[1 to 4]+dt[11 to 19]
else if dt[6 to 6]="0" and dt[9 to 9]<>"0" then dt:=" "+dt[7 to 8]+dt[9 to 10]+"/"+dt[1 to 4]+dt[11 to 19]
else if dt[6 to 6]<>"0" and dt[9 to 9]="0" then dt:=dt[6 to 8]+" "+dt[10 to 10]+"/"+dt[1 to 4]+dt[11 to 19]
else if dt[6 to 6]="0" and dt[9 to 9]="0" then dt:=" "+dt[7 to 8]+" "+dt[10 to 10]+"/"+dt[1 to 4]+dt[11 to 19];
dt
其中Viewlog.viewlog_date_time在SQL中是datetime型,我也考虑了是不是类型不匹配,但老的代码也是这样写的,且没有什么SQL语句里也没用CAST,CONVERT来转换过。百思不得其解,望高手指点一二,不胜感激!!