mardi 29 septembre 2015

Different results for a similar queries depends on format of date string in sqlite3

I have two tables in sqlite3:

sqlite> create table date_1 (date text);
sqlite> create table date_2 (date text);

Each table contains three rows with dates written in different formats:

sqlite> select * from date_1;
28.09.2015
28.08.2015
29.08.2015
sqlite> select * from date_2;
2015-09-28
2015-08-28
2015-08-29

My current date is:

sqlite> select date('now');
2015-09-29

Why do I have a different results for the next similar queries?

sqlite> select * from date_1 where date < strftime('%d.%m.%Y', 'now', '-1 day');
28.08.2015
sqlite> select * from date_2 where date < strftime('%Y-%m-%d', 'now', '-1 day');
2015-08-28
2015-08-29

Why first query don't returns '29.08.2015' too?

Aucun commentaire:

Enregistrer un commentaire