Conversions Between Data Types That Preserve the Data

Last reviewed: April 17, 1995
Article ID: Q95710
The information in this article applies to:
  • Microsoft FoxPro for MS-DOS, versions 1.02 and 2.0

SUMMARY

If some basic rules are followed, FoxPro can convert fields to different types within a database without data loss.

MORE INFORMATION

The 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        No

Note: 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-yy

Character 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 N

A 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
KBCategory: kbprg
KBSubcategory:


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: April 17, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.