Reputation: 5795
We are working with sqlite3 and have encountered one problem.
We have a database for library with several tables, in particular - items table and loans table. When we insert a new item into the loans table, we have to save the Start date and Due date of the loan. The starting date is select Date('now') and the Due date should be calculated as the Start date + exact number of days taken from the items table (= loanduration). We try to do it with following query:
update loans set Sdate=(SELECT date('now')) where CID=NEW.CID and IID=NEW.IID;
update loans set Ddate= select date(NEW.Sdate, '+' || (select loanduration from items where items.IID=NEW.IID) where CID=NEW.CID and IID=NEW.IID day|| 'day');
However, it doesnt work and we can
t find the proper solution.
Can anybody help, please?
Upvotes: 0
Views: 60
Reputation: 180020
According to the documentation, the modifier must be +NNN days
:
> SELECT date('now', '+3day');
> SELECT date('now', '+3 day');
2014-03-12
Upvotes: 1