SQLite3にDateTime.Ticksでタイムスタンプを保存したら

ぱっと見ただけじゃ時刻が分からない。ものすごい数字に強い人ならともかくも。

しかし、多分integer(C#ではlong)で保存した方がインデックスが有効になるし、速いと思うので、Ticksで保存したいと思う。

そんな場合は、こうすればよい。

select datetime(created_at/pow(10,7) – 62135888400, ‘unixepoch’, ‘localtime’) as d, * from events;

長い。unixepochに変換するためにこうなってしまう。もっと直接的に計算できる項を見つければいいんだろうけど。SQLiteではCREATE FUNCTIONできないようだし。

投稿日: 5月 23, 2009 | カテゴリー: Uncategorized | パーマリンク 3件のコメント.

  1. 帳尻あわせの数は、月によって変化するみたい。なぜかは分からない。select datetime(executed_at/pow(10,7) – 62135629200, \’unixepoch\’, \’localtime\’) as d, * from events;

  2. I have read so many articles on the topic of the blogger lovers but this piece of writing is truly a pleasant post, keep
    it up.

  3. Hello, I think your blog might be having browser
    compatibility issues. When I look at your blog in Chrome, it looks fine but when opening in Internet Explorer, it has some overlapping.
    I just wanted to give you a quick heads up! Other then that, excellent blog!

コメントを残す