I managed to create a strftime function that implements what i think it should be.
To use do the following:
add sqlite3 to your uses clause.
copy that function to your unit:
procedure StrFTime(context: PSqlite3_Context; argc: LongInt; argv: PPSqlite3_Value); cdecl;
var
Year, Month, Day: word;
FormatStr: String;
begin
if (sqlite3_value_type(argv[1]) <> SQLITE_INTEGER) and
(sqlite3_value_type(argv[1]) <> SQLITE_FLOAT) then
begin
sqlite3_result_null(context);
Exit;
end;
FormatStr := UpperCase(sqlite3_value_text(argv[0]));
DecodeDate(sqlite3_value_double(argv[1]), Year, Month, Day);
if FormatStr = '%Y' then
sqlite3_result_int(context, Year)
else
if FormatStr = '%M' then
sqlite3_result_int(context, Month)
else
if FormatStr = '%D' then
sqlite3_result_int(context, Day)
else
sqlite3_result_null(context);
end;
After the very first Open call add the following code:
sqlite3_create_function(DataSet.SqliteHandle, 'strftime', 2, sqlite_any, nil, @strftime, nil, nil);
Test and give me some feedback.
I'll built in in the next release