我正在尝试编写一个sqlite语句,该语句从表中返回一个日期,并从另一列中添加了一定天数。日期存储为YYYY-MM-DD HH:mm:ss
,天数存储为整数。
我有
SELECT strftime('%Y-%m-%d %H:%M:%S' ,
strftime('%s',transactions.date)+repeattransactions.interval*24*60*60)
FROM transactions,repeattransactions
但这给岁月和各种各样的事情增加了更多的数字。想知道我是否可以在添加日期并以相同格式输出时获得帮助?
谢谢。
最佳答案
$ sqlite3
SQLite version 3.7.7 2011-06-23 19:49:22
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> create table t (tdate, tinterval);
sqlite> insert into t values ('2011-09-08 11:11:11', 5);
sqlite> select datetime(t.tdate,'+'||t.tinterval||' days') from t;
2011-09-13 11:11:11
参见SQLite3 Date & Time Functions
关于ios - sqlite添加日期到日期,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/7350599/