Conversions Between Data Types That Preserve the DataLast reviewed: April 17, 1995Article ID: Q95710 |
The information in this article applies to:
SUMMARYIf some basic rules are followed, FoxPro can convert fields to different types within a database without data loss.
MORE INFORMATIONThe usual method for converting a field type in a database involves using the MODIFY STRUCTURE command. Below is a table that summarizes the types of field data that are possible and also indicates if data may be lost in the translation. "Yes" indicates that the data will be preserved, "No" indicates that data will be lost, and "Possibly" depends on the data involved.
Data Type Char Numeric Float Date Logical Memo
Char Possibly Possibly Possibly Possibly No Numeric Yes Yes No No No Float Yes Yes No No No Date Yes No No No No Logical Yes No No No No Memo No No No No NoNote: Depending on the string to be converted, a character field can be converted into any other field, except a memo field. When a character field is converted to a float or numeric, only numeric characters are converted. In a numeric field, the characters will be rounded unless a decimal point is part of the numeric field definition. Moreover, when a character field is converted to a numeric field, the sizes of the fields must match or data will be lost. Character fields can be converted to date fields if the data in the character field is formatted as a valid date string. The following date formats are supported by default:
mm/dd/yy mm-dd-yyCharacter fields can also be converted to logical fields if the first letter of the field is one of the following and is in uppercase:
T F Y NA numeric or float field can be converted to a character field as long as the field is large enough to hold the converted data. If the field is not large enough, data loss will occur. Date fields can be converted only to character fields without the risk of data loss. If you attempt to convert the date field to another format, the data will be lost and a blank field will be created. A logical field can be converted only to a character field without the risk of data loss. The logical data that is stored is always converted to a T or F character.
|
Additional reference words: FoxDos 1.02 2.00 conversion data types
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |