Crystal reports 按代码格式化公式?
我使用以下公式作为交叉表报表的分组:Crystal reports 按代码格式化公式?,crystal-reports,Crystal Reports,我使用以下公式作为交叉表报表的分组: {Command.Year} & ' ' & {Command.RF Period} 年是一个小整数,周期是一个小整数 问题在于,报告中显示: 2009.00 9.00 数据库值实际上是: 2009年9月 我无法通过格式化删除小数位,因为它们一起出现在公式中 最终,我希望它是: 2009 09 编辑: 我找到了这个链接: 现在,我的代码在这段时间内如下所示: WhileReadingRecords; StringVar text
{Command.Year} & ' ' & {Command.RF Period}
年是一个小整数,周期是一个小整数
问题在于,报告中显示:
2009.00 9.00
数据库值实际上是:
2009年9月
我无法通过格式化删除小数位,因为它们一起出现在公式中
最终,我希望它是:
2009 09
编辑:
我找到了这个链接:
现在,我的代码在这段时间内如下所示:
WhileReadingRecords;
StringVar text := Totext ( {Command.RF Period} , 6 , "" ) ; //put your numeric field in this line
NumberVar end := length ( text ) ;
NumberVar clip :=
(if Val ( text [ end - 6 to end ] ) = 0 then 1 else 0 ) +
(if Val ( text [ end - 5 to end ] ) = 0 then 1 else 0 ) +
(if Val ( text [ end - 4 to end ] ) = 0 then 1 else 0 ) +
(if Val ( text [ end - 3 to end ] ) = 0 then 1 else 0 ) +
(if Val ( text [ end - 2 to end ] ) = 0 then 1 else 0 ) +
(if Val ( text [ end - 1 to end ] ) = 0 then 1 else 0 ) +
(if Val ( text [ end - 0 to end ] ) = 0 then 1 else 0 ) ;
text [ 1 to Length ( text ) - clip ]
但是,我不使用Crystal语言,我使用VB。如果0不是以1开头,如何在句点前面附加0
现在的问题是9月(9日)出现在10月、11月和12月之后,因为9月在1之后
有人吗 ToText函数对于这类事情非常有用,不需要循环。在Crystal的VB语法中:
Formula = ToText({Command.Year}, 0, "") & " " & ToText({Command.RF Period}, "00")
如果{Command.Year}和{Command.RF Period}是您描述的整数,则应该可以这样做