All Visual FoxPro data has a type — a description of the permissible values and range and size of those values. Once you specify the type of data you are using, Visual FoxPro can efficiently store and manipulate the data.
Variables and arrays hold a subset of the available Visual FoxPro data types. Additional data types are available only for fields in a table. To add a field of a specific type to a table programmatically, specify the field type with a letter abbreviation. For more information, see the description for FieldType in CREATE TABLE - SQL.
You specify the type of data to be stored in each field of a table when you create the table. The type of data in a variable or array element is determined by the value you store in the variable or array element. The following table lists the data types in Visual FoxPro.
Visual FoxPro Data Types
Data type | Description | Size | Range |
Character | Any text | 1 byte per character to 254 | Any characters |
Currency | Monetary amounts | 8 bytes | - 922337203685477.5807 to 922337203685477.5807 |
Date | Chronological data consisting of month, year, and day | 8 bytes | When using strict date formats, {^0001-01-01}, January 1st, 1 A.D to {^9999-12-31}, December 31st, 9999 A.D. |
DateTime | Chronological data consisting of month, year, day, and time | 8 bytes | When using strict date formats, {^0001-01-01}, January 1st, 1 A.D to {^9999-12-31}, December 31st, 9999 A.D., plus 00:00:00 a.m. to 11:59:59 p.m. |
Logical | Boolean value of true or false | 1 byte | True (.T.) or False (.F.) |
Numeric | Integers or fractions | 8 bytes in memory; 1 to 20 bytes in table |
- .9999999999E+19 to .9999999999E+20 |
Variant | A variant can contain any of the Visual FoxPro data types and the null value. Once a value is stored to a variant, the variant assumes the data type of the data it contains. Variants are designated with an e prefix in language syntax. |
See data types above. | See data types above. |
In addition, Visual FoxPro provides data types that apply only to fields in tables.
Visual FoxPro Field Types
Field type | Description | Size | Range |
Double | A double-precision floating-point number | 8 bytes | +/-4.94065645841247E-324 to +/-8.9884656743115E307 |
Float | Same as Numeric | 8 bytes in memory; 1 to 20 bytes in table |
- .9999999999E+19 to .9999999999E+20 |
General | Reference to an OLE object | 4 bytes in table | Limited by available memory |
Integer | Integer values | 4 bytes | -2147483647 to 2147483647 |
Memo | Reference to a block of data | 4 bytes in table | Limited by available memory |
Character (Binary) | Any character data you want to maintain without change across code pages | 1 byte per character to 254 | Any characters |
Memo (Binary) | Any memo field data you want to maintain without change across code pages | 4 bytes in table | Limited by available memory |
Tip You can use the TYPE( ) function to determine the type of data stored in a variable, array element, or field.
Each data type has its own characteristics, including storage size:
Data Type Storage Differences
To see a list of the functions you can use with each data type, see Language Categories.