Converting data for datetime values
You can use the Informix® ESQL/C library functions dtcvasc(), dtcvfmtasc(), dttoasc(), and dttofmtasc() to explicitly convert between DATETIME 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 DATETIME value to a DATE value:
Procedure
- Use the dtextend() function to adjust
the DATETIME qualifier to
year to day
. - Apply the dttoasc() function to create
a character string in the form
yyyy-mm-dd
. - Use The rdefmtdate() function with a
pattern argument of
yyyy-mm-dd
to convert the string to a DATE value.