Sqlite: как привязать и вставить дату из C ++?

Использование C ++ (Visual Studio) и sqlite. Как привязать дату к параметру?

sqlite3_stmt *statement;

const char *sql = 
    "INSERT INTO employees "
        "(full_name,"
        "date_started)" 
    " VALUES "
        "(@full_name,"
        "@date_started)";

sqlite3_prepare_v2(database_, sql, -1, &statement, NULL);

int parameterIndex = sqlite3_bind_parameter_index(statement, "@full_name");
sqlite3_bind_text(statement, parameterIndex, "John Smith", -1, SQLITE_TRANSIENT);

parameterIndex = sqlite3_bind_parameter_index(statement, "@date_started");

// <??? what goes here ???>
// I want to include the local current time, so I want to know:
// 1. what's the best way to get local time in C++
// 2. and what goes here for the date binding

sqlite3_step(statement);

sqlite3_finalize(statement);

Примечание: я не хочу устанавливать текущее время с помощью sql (например, CURRENT_TIMESTAMP и т. Д.)

5
задан User 25 August 2011 в 21:57
поделиться