cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Crystal Reports ToText Function

Former Member
0 Likes
27,054

Hello

I have a report that takes the current year and converts it to text using the ToText function e.g. ToText(Year(CurrentDate))

In Crystal this returns 2013

When I run the same report using the .NET runtimes for Crystal 2011, the same formula return 2,013.00

I know that the ToText function has extra parameters to handle formatting, however, I expect the results to be consistent between Crystal Reports and runtimes. Is there an over-ride for the runtimes (registry setting perhaps) that can be used to make the results formatted like Crystal Reports?

Accepted Solutions (1)

Accepted Solutions (1)

0 Likes

Hi Wil,

The correct format would be:

ToText(Year(CurrentDate),0)

0 = no decimal places when converting a number to a string.

Viewer is doing what it should, Report Designer may have a bug.

Don

Answers (4)

Answers (4)

aarthir
Discoverer
0 Likes

Thanks so much. It worked!

ido_millet
Active Contributor
0 Likes

Sure. Use this

ToText(CurrentDate, "MM")

And in a similar way, this is a slightly simpler solution for the original year question:

ToText(CurrentDate, "yyyy")
aarthir
Discoverer
0 Likes

Hi,

We are using Crystal reports to produce positive pay file and we have a formula

totext(month({@Convert Date}),0)

that extracts month from the date. Formula is working fine for months that are two digits from October through December but for January through September , instead of extracting 01 for month for January, the result only shows 1 .

Is there a better formula that I can use so that the month on the positive pay crystal report to appear as 01,02 for January, February and 10,11,12 for October through December.

Appreciate any input.

Thanks,
Aarthi

Former Member
0 Likes

Hi Wil

ToText(Year(CurrentDate),0) will give you "2,013".

Try

ToText(Year(CurrentDate),0,"") this will give you "2013"

Regards
Damien