Sqlite - standard timestamp "now + few days"
1 answer
Yes, it can be done as in the following example:
sqlite> create table foo (i int, j text default (datetime('now', '+5 days')));
sqlite> insert into foo (i) values (1);
sqlite> select * from foo;
1|2012-04-11 07:49:04
sqlite> insert into foo (i) values (2);
sqlite> select * from foo;
1|2012-04-11 07:49:04
2|2012-04-11 07:49:14
If you only want to keep part of the date, use date
instead datetime
. Here I am using datetime
to show that the default expression is evaluated when inserted into the table, not when the table is created.
+2
user610650
source
to share