Crystal Reports Online Training

Learn Online, Anytime, Anywhere

Step-by-step tutorials and online videos.

Click Here To Learn More »

9.04 Converting Data Types

Converting Data Types

Basic syntax is a type safe language that requires all constants and variables in the same formula to be of the same data type. It also requires you to pass constants and variables as parameters using the exact data type that the formula expects. Even though the data types in Basic syntax are fairly simple, you still have to make sure that they are compatible. Fortunately, all the necessary type conversion formulas are available. Table 9-5 lists the conversion functions.

Table 9-5. Conversion Functions

Conversion Function Description
CBool(number), CBool(currency) Convert to Boolean.
CCur(number), CCur(string) Convert to Currency.
CDbl(currency), CDbl(string), CDbl(boolean)
Convert to Number. Equivalent to ToNumber(). See the section “Formatting Values for Output”. CStr()
Convert to String. Equivalent to ToText(). CDate(string), CDate(year, month, day), CDate(DateTime)
Convert to Date. CTime(string), CTime(hour, min, sec), CDate(DateTime)
Convert to Time. CDateTime(string),
CDateTime(date), CDateTime(date, time),
CDateTime(year, month, day) Convert to DateTime
CDateTime(year, month, day, hour, min, sec)
Convert to DateTime. ToNumber(string), ToNumber(boolean)
Convert to a Number. ToText()
Convert to String. Same as CStr(). IsDate(string), IsTIme(), IsDateTime()
Test a string for being a valid date/time. IsNumber(string)
Test a string for being a valid number. ToWords(number),
ToWords(number, decimals) Convert a number to its word equivalent.

Most of the above functions work the same as the similarly named .NET functions. The CBool() function takes a number or currency value and converts...

Get UNLIMITED Crystal Reports Online Training!

Click Here To Start Your Training!

1500+ Tutorial Pages

Complete Crystal Reports Online Training with over 1,500 pages of better than book quality Crystal Reports tutorials.

Step-by-step Online Videos

Learn at your own pace from the comfort of your home! Pause, rewind and watch online training videos anytime!

Online Community

Members-only community where you can post and answer questions. The community is checked on a regular basis by best selling Crystal Reports book author Brian Bischof to help answer your questions.

Cut & Paste Source Code

Save time with simple cut and paste source code you can use right now in your next report!

Click Here To Start Your Training!