On Fri, Jan 27, 2012 at 1:12 PM, Bill McCormick <[email protected]>wrote:
> I have a date stored in a numeric field like this: 2012-01-27 16:47:50.
>
> I want to update the date using the date function, like this:
>
> update table set TIME_STAMP = date('TIME_STAMP', '+ 2 years');
>
> Reference:
> http://www.sqlite.org/lang_**datefunc.html<http://www.sqlite.org/lang_datefunc.html>
>
> I also tried this:
> update table set TIME_STAMP = date(TIME_STAMP, '+ 2 years');
>
> Neither form works correctly, it just clears the field.
>
> What am I doing wrong?
>
Here is a demonstration of how to do it:
SQLite version 3.7.10 2012-01-16 13:28:40
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> CREATE TABLE t1(x);
sqlite> INSERT INTO t1 VALUES('2012-01-27 13:13:00');
sqlite> SELECT * FROM t1;
2012-01-27 13:13:00
sqlite> UPDATE t1 SET x = datetime(x,'+2 years');
sqlite> SELECT * FROM t1;
2014-01-27 13:13:00
sqlite>
> ______________________________**_________________
> sqlite-users mailing list
> [email protected]
> http://sqlite.org:8080/cgi-**bin/mailman/listinfo/sqlite-**users<http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users>
>
--
D. Richard Hipp
[email protected]
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users