SQLite: Insert current timestamp with milliseconds precision
sql, sqlite
Solution
Date and time functions reference says `datetime(timestring, [modifiers...])` is equivalent to `strftime('%Y-%m-%d %H:%M:%S', timestring, [modifiers...])`.
If you want fractional seconds you must use `%f` not `%S`. So use `strftime('%Y-%m-%d %H:%M:%f', 'now') `.
CREATE TABLE test (timestamp DATETIME);
INSERT INTO test VALUES(strftime('%Y-%m-%d %H:%M:%f', 'now'));
Problem
I'm trying to insert the current timestamp into SQLite: ``` CREATE TABLE test (timestamp DATETIME); INSERT INTO test VALUES(datetime('now')); ``` This does create the timestamp, but only with seconds-precision (the timestamp looks like `2013-12-17 07:02:20`). Is it possible to add the milliseconds, as well?