simonw / sqlite-history

Track changes to SQLite tables using triggers
Apache License 2.0
108 stars 2 forks source link

Store changed timestamp in ms since the epoch, not seconds #6

Closed simonw closed 1 year ago

simonw commented 1 year ago

I want more accurate timestamps, but I still want them to fit in an integer field.

simonw commented 1 year ago

Figured out the recipe for that here: https://github.com/simonw/sqlite-history/issues/1#issuecomment-1501013498

It's a bit weird!

cast((julianday('now') - 2440587.5) * 86400.0 * 1000 as integer)
simonw commented 1 year ago

Got a TIL out of this: https://til.simonwillison.net/sqlite/unix-timestamp-milliseconds-sqlite