They can be compared as text, as long as the actual values are what you expect from them. This is problem.
Comparing dates, like text, how it works with scissors. But SQLite makes you work with scissors all the time.
sqlite> create table test (d1 datetime primary key); sqlite> insert into test values ('2011-31-31 08:63:00'); sqlite> select * from test; 2011-31-31 08:63:00
. dbms, which complies with SQL standards, causes an out-of-range error when trying to insert or update values such as "2011-31-31 08:63:00". But SQLite allows you to embed anything. You can even insert "Catcall" in the datetime column. (Try it.)
SQLite gives you the same "work with scissors" behavior if you use text.
sqlite> create table test (d1 varchar(25) primary key); sqlite> insert into test values ('2011-31-31 08:63:00'); sqlite> select * from test; 2011-31-31 08:63:00
If the values do not meet your expectations, you are likely to see the following behavior.
sqlite> create table test (d1 varchar(25), d2 varchar(25)); sqlite> insert into test values ('2011-01-01 08:00:00', '2011-01-01 08:15:00'); sqlite> select d1<d2 from test; 1 sqlite> update test set d2 = '2011+01-01 08:15:00'; sqlite> select d1<d2 from test; 0
Mike Sherrill 'Cat Recall'
source share