Crystal Reports将当前月份显示为2位数字段

时间:2014-01-07 21:15:32

标签: crystal-reports

我想知道是否有人可以帮忙吗?我需要将当前月份显示为2位数字段。 IE 1月为01 二月为02 三月为03 等等,直到 十月十日 11月11日 12月为12日

我使用的公式是:ToText(“0”& Month(CurrentDate)) 但显示1月为01.00 即需要删除小数点和小数位

非常感谢,Rob

3 个答案:

答案 0 :(得分:3)

试试这个:

ToText( CurrentDate, "MM")

答案 1 :(得分:0)

ToText功能会自动将您提供的日期转换为您想要的任何格式。您不需要使用Month函数。根据文档,您只需提供日期和输出格式。本月,您使用“MM”。

ToText(CurrentDate, "MM")

根据文档,这些是您可以使用的有效字符串

Pattern  Result
d        Numeric day of month without leading zero (1, 7, 31)
dd       Numeric day of month with leading zero (01, 07, 31)
ddd      Three day abbreviation of day of week (Mon, Sat)
dddd     Full name of day of week (Monday, Saturday)
M        Numeric month without leading zero (1, 7, 12)
MM       Numeric month with leading zero (01, 07, 12)
MMM      Three letter abbreviation of month (Jan, Feb, Mar)
MMMM     Full name of month (January, February, March)
yy       Last two digits of year (11, 14, 22)
yyyy     Full four digits of year (2011, 2014, 2022)

答案 2 :(得分:0)

要添加上述内容,如果你需要返回类似Mar-17的内容,那么:

totext({Command.DocDate}," MMM")+' - ' + totext({Command.DocDate}," yy")