|
|||||||||
|
Crystal Reports Tools: Improve Performance While Saving Time and Money |
|
Crystal Reports: ToText Function
Use ToText with date format masks The ToText function is very flexible with many options. We recently were shown a formula where a formula was being used to display a February date field as "200602". The original formula used Left and Mid functions and field concatenation. We pointed out that they could remove all that and use the ToText function directly with a formula of
There is a long list of the different values you can put in that format string after the date. You can even include the hour, minute, and second values from a date time field. One thing to be wary of is that those format strings are case sensitive. If you use "mm" you get the minutes value of the field, while "MM" returns a date month value. Sorting: We recommend using "MM" rather than "M." Why: The first format returns a month with a leading zero (if required). This makes sorting the string a lot easier. We don’t want that report to sort January, October, November, December, March, April…. Similarly use "dd" instead of "d" to display days with a leading zero. We find using ""HH" rather than "hh" a better choice, becausethat displays hours in 24 hour clock format (which many people prefer, for obvious reasons). So that would display a 2pm time as "14." If time is an important aspect of the data, using a 24 hour clock eliminates an obvious confusion point. We mentioned in another article that the noon cutover can seem strange when 11am is followed by 12pm, and then 1pm. Some might mistakenly view 12pm as being at midnight rather than midday, or 12AM as being midday rather than midnight. With the 24 hour clock, this is not an issue. Other features of ToText function: If you are using a number field as the first value in ToText, there are some other format values available. For example you can use ToText to display a number as a string with leading zeros, or you can specify the number of decimals and characters to use for decimal point and as a thousand separator. Or you can eliminate them entirely. It is well worth spending some time reading the help files on the varied uses of the ToText function.
Now, here's a neat way to use text in a Crystal Report. Include text in your Crystal reports--dynamically. cViewTEXT lets you dynamically load text into a Crystal Report. You could use it for a custom disclaimer in the page footer, or to add a custom message. The text source file can be plain text, html, or rich text. If you use HTML or Rich Text, you can then format it using the Text Interpretation feature. Add punch to your Crystal Reports, by including text dynamically. A properly designed report can use dynamic text inclusion such that the text displayed depends on the data and the formulas that manipulate the data. This can take your reporting system to a whole new level.
This article is copyrighted by Crystalkeen, Mindconnection, and Chelsea Technologies Ltd. It may be freely copied and distributed as long as the original copyright is displayed and no modifications are made to this material. Extracts are permitted. The names Crystal Reports and Seagate Info are trademarks owned by Business Objects. |