tags:

views:

471

answers:

2

What are the sqlite equivalents of INTERVAL and UTC_TIMESTAMP> For example, imagine you were "porting" the following SQL from MySQL to sqlite:

SELECT mumble
  FROM blah
 WHERE blah.heart_beat_time > utc_timestamp() - INTERVAL 600 SECOND;
+2  A: 

There's no native timestamp support in sqlite.

I've used plain old (64-bit) integers as timestamps, representing either micro- or milliseconds since an epoch.

Therefore, assuming milliseconds:

SELECT mumble
  FROM blah
WHERE blah.heart_beat_time_millis > ? - 600*1000;

and bind system time in milliseconds to the first param.

laalto
A: 

there is LOCAL_TIMESTAMP in SQLite, but it's GMT.