Data Type is used to store data in variable or in computer memory to used in next or
future bussiness data calculation.
Suppose we wand to do addition of 2 number then we will
store 2 number in 2 variable say num1 and num2 and their addition
we store in sum variable.
We can manipulate this data with formulas, but we must be careful to
do it properly.
There are two type of data types in crystal report.
1] Simple Data type
2] complex Data type.
1] Simple data types
The simple data types are number, currency, string, date, time, datetime, and Boolean.
1) Number :
The number type includes positive and negative integers and real numbers.
When you enter number data, however, don’t separate each group of three
digits with commas. The only non-numeric characters allowed in a number are
the decimal point and the negation sign.
Syntax:
DataType Variable Name [=initialization(optional)] ;
Example:
numberVar Age:= 10 ;
Following are examples of number:
42
-273
3.1415927
93000000.
We can perform addition, subtraction, multiplication, and division operations on number data.
2) Currency:
Currency data is similar to number data, except it starts with a dollar sign
($) and numbers to the right of the decimal point are rounded differently.
Syntax:
DataType Variable Name [=initialization(optional)] ;
Example:
currencyVar Salary:= $1200 ;
Following are a few examples of currency type data:
$10.15
$14000
-$40000000.
3) String:
String is group of character. We can convert a string to all uppercase or all lowercase.
Strings must be enclosed in either single or double quotes.
Syntax:
DataType Variable Name [=initialization(optional)] ;
Example:
stringVar strMsg:= "Welcome" ;
Here are a few strings Exaple:
"Hi, I am Ram."
"$10.20"
‘You can put "quoted text" within a string.’
‘You can even include an apostrophe in a string’’s text’
4) Date, time, and datetime:
The date data type store dates, the time data type store
times, and datetime data type store a combination of the date and time.
Datetime values are not strings or numbers. They are literals, which are handled differently from the way either strings or
numbers are handled. Datetime literals are enclosed in pound (#) signs. This differentiates them from strings
(which are quoted) and numbers
Example:
dateVar dtStartTime:= #7/20/1969# ;
timeVar tmTime:= TimeValue( "8:00") ;
dateTimeVar dttm:= #7/20/1969 16:18:00#; ;
Following are some examples of values that can be stored in the datetime data type:
#July 20, 1969#
#20 Jul 1969 4:18 pm#
#7/20/1969 16:18:00#
#7/20/1969#
#4:18 pm#
5) Boolean:
Boolean data has only two values, True and False. Crystal Reports accepts
Yes and No as synonyms for True and False.
Example:
booleanVar isFound:= False ;
2] Complex Types :
Range types and
array types are more complex data types.
6) Range data types:
Crystal Reports enables we to restrict the values of data elements to a specified range for all data types except Boolean.
For example:
A range of 70 To 100 includes values between 70 and 100. Both 70 and 100 are included in the range.
70_To_100 includes values between 70 and 100. Both 70 and 100 are excluded.
70_To 100 includes values between 70 and 100. 70 is excluded but 100 is included.
UpTo 100 includes all numbers up to and including 100, but none beyond.
"A" To_ "Z" includes all character strings starting with an uppercase
letter, except for strings starting with "Z".
7) Array data types:
Arrays are ordered lists of values that are all the same type.
In Crystal Reports,an array can be a simple type or a range type.
Array elements are enclosed in
square brackets.
To access elememt from array used subscript.(A subscript specifies[position] a particular element of an array.)
No comments:
Post a Comment
Please do not enter any spam link in the comment box.