Converting data for interval values
You can use the Informix® ESQL/C library functions incvasc(), incvfmtasc(), intoasc(), and intofmtasc() to explicitly convert between INTERVAL column values and character strings.
About this task
For example, you can perform conversions between the DATETIME and DATE data types with Informix® ESQL/C library functions and intermediate strings.
To convert a DATE value to a DATETIME value:
Procedure
- Declare a host variable with a qualifier of
year to day
(or initialize the qualifier with the value that the TU_DTENCODE(TU_YEAR,TU_DAY) macro returns). - Use the rfmtdate() function with a pattern
of
yyyy-mm-dd
to convert the DATE value to a character string. - Use the dtcvasc() function to convert the character string to a value in the prepared DATETIME variable.
- If necessary, use the dtextend() function to adjust the DATETIME qualifier.