On 23 Aug 2012, at 3:14am, YAN HONG YE <yanhong...@mpsa.com> wrote:

> create table test( Date datetime);
> insert test now();
> select date+2 as bbb,date-12 as cc from test;
> the result is 
> 2014,2000
> I wanna know how to add any day use sql command

There is no field type 'datetime'.  Dates are often expressed as TEXT.

Do not use 'Date' as a fieldname because the word 'Date' is used by SQLite for 
a keyword.

sqlite> CREATE TABLE test (thisDate TEXT);
sqlite> INSERT INTO test (thisDate) VALUES (date('now'));
sqlite> SELECT * from test;
2012-08-23
sqlite> SELECT date(thisDate,'+2 day'), date(thisDate,'-12 day') FROM test;
2012-08-25|2012-08-11

For documentation see this page:

<http://www.sqlite.org/lang_datefunc.html>

Simon.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to