Clayton
Clayton

Reputation: 6271

Convert MYSQL_TIME data type to char * or C++ string

I am using the MySQL C API within a C++ application. I have a column in my result set that is of the type MYSQL_TIME (part of mysql.h).

Is there a way to convert MYSQL_TIME to a char* or to a C++ string?

Upvotes: 4

Views: 1271

Answers (1)

Clayton
Clayton

Reputation: 6271

I figured it out:

fprintf(stdout, " %04d-%02d-%02d %02d:%02d:%02d (%ld)\n",
                 ts.year, ts.month, ts.day,
                 ts.hour, ts.minute, ts.second,
                 length[3]);

where length[3] contains the length of ts.

Upvotes: 3

Related Questions