To send temporal data values, create a prepared statement using
mysql_stmt_prepare(). Then, before
calling mysql_stmt_execute() to
execute the statement, use the following procedure to set up each
temporal parameter:

In the MYSQL_BIND structure associated with
the data value, set the buffer_type member
to the type that indicates what kind of temporal value you're
sending. For DATE,
TIME,
DATETIME, or
TIMESTAMP values, set
buffer_type to
MYSQL_TYPE_DATE,
MYSQL_TYPE_TIME,
MYSQL_TYPE_DATETIME, or
MYSQL_TYPE_TIMESTAMP, respectively.

Set the buffer member of the
MYSQL_BIND structure to the address of the
MYSQL_TIME structure in which you pass the
temporal value.

Fill in the members of the MYSQL_TIME
structure that are appropriate for the type of temporal value
to be passed.

To retrieve temporal values, the procedure is similar, except that
you set the buffer_type member to the type of
value you expect to receive, and the buffer
member to the address of a MYSQL_TIME structure
into which the returned value should be placed. Use
mysql_stmt_bind_result() to bind
the buffers to the statement after calling
mysql_stmt_execute() and before
fetching the results.

Here is a simple example that inserts
DATE,
TIME, and
TIMESTAMP data. The
mysql variable is assumed to be a valid
connection handle.