c++ - how to get day of week from sqlite date and time string? -
i using sqlite datetime commands get, set , manipulate date , time strings. first construct sql command in const char* , execute command using sqlite3_exec while using call function fetch results if (select from) commands.
orderdatabaserc = sqlite3_exec(orderdatabase, psql[i], callback, 0, &zerrmsg);
now want know day of week (mo-su) , month (jan-dec) date , time string.
how do in sqlite? documentation says can wiser documentation , examples hard find.
let me give examples of sql commands using:
"create table ordertable (orderid integer primary key asc, customerid integer, ordervalue, orderdescription, orderdatetime date, orderduedatetime date)" "create trigger insert_ordertable_orderdate after insert on ordertable begin update ordertable set orderdatetime = datetime('now') rowid = new.rowid; end;" "update ordertable set orderduedatetime = datetime('" << iorderdatetime << "', '+1 day') orderid = " << orderid
so need able know day of week , month of date time string.
according suggestion below have constructed following statement , fired off sqlite3_exec:
"select strftime('%a', orderdatetime) ordertable orderid = " << orderid;
then in callback function following code (azcolname[i] seems come copy of sql statement:
char* columnname; for(int i=0; i<argc; i++) { columnname = azcolname[i]; string dayofweek; if(strcmp(columnname, "strftime('%a', orderdatetime)")==0) { dayofweek = string(argv[i]); } ... }
but crashes on
dayofweek = string(argv[i]);
use strftime() %w
, %m
.
Comments
Post a Comment