Converting data for interval values

You can use the 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 library functions and intermediate strings.

To convert a DATE value to a DATETIME value:

Procedure

  1. 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).
  2. Use the rfmtdate() function with a pattern of yyyy-mm-dd to convert the DATE value to a character string.
  3. Use the dtcvasc() function to convert the character string to a value in the prepared DATETIME variable.
  4. If necessary, use the dtextend() function to adjust the DATETIME qualifier.