It looks to me like the dateCmd function in th_main.c could be cloned and modified to create a new function to evaluate a string parameter as an SQL query.

Of course, it might be desirable to add checking to this new queryCmd function before giving the string to sqlite.