Working with Conversions
Go Up to API Guide
InterBase uses a proprietary format for internal storage of
DATE data, but provides the following API calls for translating to and from this format:
isc_decode_sql_date()converts the InterBase internal date format to the C
isc_encode_sql_date()converts the C
datestructure to the internal InterBase date format.
isc_decode_sql_time()converts the InterBase internal time format to the C
isc_encode_sql_time()converts the C
timestructure to the internal InterBase time format.
isc_decode_timestamp()converts the InterBase internal timestamp format to the C
timestampstructure; this call was formerly
isc_encode_timestamp()converts the C
timestampstructure to the internal InterBase timestamp format; this call was formerly
These calls merely translate date-time (
TIMESTAMP) data between formats; they do not read or write date-time data directly. Date-time data is read from and written to the database using standard DSQL syntax processed with the
isc_dsql family of API calls.
- Note: The
DATEdata type holds only date information in dialect 3 and is not permitted in dialect 1 to avoid ambiguity. Beginning with InterBase 6, when an older database is migrated to dialect 1, all columns that previously had a
DATEdata type are automatically converted to
TIMESTAMP. To store migrated data in a
DATEcolumn in dialect 3, you must create a new column in dialect 3 that has the
DATEdata type, and then move the data into it. InterBase does not allow you to use
ALTER COLUMNto change a
TIMESTAMPdata type to a
DATEdata type because of potential data loss.
InterBase also requires that numbers entered in database and transaction parameter buffers be in a generic format, with the least significant byte last. Signed numbers require the sign to be in the last byte. Systems that represent numbers with the most significant byte last must use the
isc_portable_integer() API function to reverse the byte order of numbers entered in database parameter buffers (DPBs) and transaction parameter buffers (TPBs). When numeric information is returned by information calls on these systems,
isc_portable_integer() must be used once again to reverse the byte ordering.
For more information about using DSQL to read and write data, see Working with Dynamic SQL.
- Converting Date and Times from InterBase to C Format
- Converting Dates from C to InterBase Format
- Reversing the Byte Order of Numbers