Handling Date and Time Values

Date-and-time related data types are handled through different conversion protocols depending on the database systems. To achieve portability, DB Link offers a feature that allows date-and-time values to be sent and retrieved as objects of the class IldDateTime.

The DB Link class IldDateTime is a transparent container where you can put or get the separate components of a date-and-time value. Its fields extend the time precision to milliseconds.

Note: The millisecond precision of the class IldDateTime introduces a small discrepancy when connected to Informix, where a millionth of a second precision is possible.

After turning the date as string feature off, you can use an IldDateTime object just like any other data type.

{

IldDateTime* dt = new IldDateTime(1996, 3, 2); // 1996/03/02

request->setParamValue(dt, 1);

}

{

// Print selected item values.

do {

if (!request->fetch())

IldDisplayError("Fetch failed:", request);

else if (request->hasTuple()) {

cout << request->getColStringValue(0) << "\t";

IldDateTime dt = request->getColDateTimeValue(1);

if (request->isErrorRaised())

IldDisplayError("Cannot retrieve DateTime: ", request);

else {

cout << dt.getYear() << "/" << dt.getMonth() << "/"

<< dt.getDay() << " " << dt.getHour() << ":"

<< dt.getMinute() << ":" << dt.getSecond() << endl;

}

}

} while (request->hasTuple());

}

These two member functions raise an error of type ILD_TYPE_MISMATCH if the date as string feature is turned on.

At creation, all fields of an IldDateTime object are initialized by default at zero.