English 中文(简体)
更新记录时,时间不超过分钟
原标题:Updating records older than n minutes
  • 时间:2011-02-22 10:07:14
  •  标签:
  • sqlite

I have a sqlite database with a datatime field called last_accessed and another field called stale.

我如何更新超过5分钟的记录的渠道?

e.g.

这似乎不可行。

• 更新我的板块结构,其中(现为)——最后是获得;300;

In fact select datetime( now ) - 2011-02-22 08:48:34 ; returns 0.

我怎样做算术?

EDIT: Since I m converting last_accessed to a datetime and really it just needs to be a seconds field. Do you think I should convert that field to seconds field instead. Then I won t need to do something like strftime( %s ,time( now )) - strftime( %s ,last_accessed)?

Edit2: There is no difftime function as far as I can tell. I discovered you have to use strftime( %s , datetime( now )) - ... format to make it work. However, instead I ve converted simply to an integer field where I m storing time(NULL) directly.

问题回答

I think it should be

select datetime( now ) - datetime( 2011-02-22 08:48:34 );

参看examples

如果有人问,如何正确进行日期/时间计算,则回答这个问题。

The correct answer is:

• 更新我的板块结构=1,其中体力(百分比、日期(现为)——体力(百分比,最后为获取)和大于300;

然而,我实际上不需要表格中的日期格式,而是选择了数字领域。 我不想再寻求这一问题的答案。

感谢。





相关问题
sqlite3 is chopping/cutting/truncating my text columns

I have values being cut off and would like to display the full values. Sqlite3 -column -header locations.dbs " select n.namelist, f.state, t.state from names n left join locations l on l.id = n.id ...

Entity Framework with File-Based Database

I am in the process of developing a desktop application that needs a database. The application is currently targeted to SQL Express 2005 and works wonderfully. However, I m not crazy about having ...

Improve INSERT-per-second performance of SQLite

Optimizing SQLite is tricky. Bulk-insert performance of a C application can vary from 85 inserts per second to over 96,000 inserts per second! Background: We are using SQLite as part of a desktop ...

Metadata for columns in SQLite v2.8 (PHP5)

How can I get metadata / constraints (primary key and "null allowed" in particular) for each column in a SQLite v2.8 table using PHP5 (like mysql_fetch_field for MySql)? sqlite_fetch_column_types (OO:...

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签