2013-12-17 17 views
8

Sto cercando di inserire il timestamp corrente in SQLite:SQLite: Inserire timestamp corrente con precisione millisecondi

CREATE TABLE test (timestamp DATETIME); 
INSERT INTO test VALUES(datetime('now')); 

Ciò crea il timestamp, ma solo con secondi precisione (il timestamp assomiglia 2013-12-17 07:02:20). È possibile aggiungere anche i millisecondi?

risposta

9

Date and time functions reference dice datetime(timestring, [modifiers...]) equivale a strftime('%Y-%m-%d %H:%M:%S', timestring, [modifiers...]).

Se si desidera frazionari secondi, è necessario utilizzare %f non %S. Quindi utilizzare strftime('%Y-%m-%d %H:%M:%f', 'now').

+0

In realtà, utilizzo 'replace (strftime ('% Y% m% d% H% M% f', 'now'), '.', '')' Come lo memorizza come numerico. –

Problemi correlati