See in section 4.1, Sort Order. Any 
integer is less than any text. So you'll want to have both as one of the number 
types to do valid comparison.

4.1 Sort Order
The results of a comparison depend on the storage classes of the operands, 
according to the following rules:

    A value with storage class NULL is considered less than any other value 
(including another value with storage class NULL).

    An INTEGER or REAL value is less than any TEXT or BLOB value. When an 
INTEGER or REAL is compared to another INTEGER or REAL, a numerical comparison 
is performed.

    A TEXT value is less than a BLOB value. When two TEXT values are compared 
an appropriate collating sequence is used to determine the result.

    When two BLOB values are compared, the result is determined using memcmp().

sqlite> select typeof(strftime('%s', '2017-10-11 10:04:43') + 300);
typeof(strftime('%s', '2017-10-11 10:04:43') + 300)

sqlite> select typeof(strftime('%s', '2017-10-11 10:04:43'));
typeof(strftime('%s', '2017-10-11 10:04:43'))

David Raymond | GIS Engineer | TomTom | Lebanon, NH, United States
e-mail:  | office +1 603 306 8498 |

-----Original Message-----
From: sqlite-users [] On 
Behalf Of Eric Bollengier
Sent: Wednesday, October 11, 2017 8:55 AM
Subject: [sqlite] Possible bug with strftime('%s') < strftime('%s')


I have noticed a problem in SQLite 3.20.1 for a simple operation based
on strftime('%s').

With SQLite 3.20.1 and 3.6.18

sqlite> select (strftime('%s', '2017-10-11 10:04:43') + 300) < 
strftime('%s', '2017-10-11 10:04:43');


If I use the CAST operator on the second member, it works

sqlite> select
(strftime('%s', '2017-10-11 10:04:43') + 300) <  CAST(strftime('%s',
'2017-10-11 10:04:43') as decimal);


If I use the following query, it works too:

sqlite> select
(strftime('%s', '2017-10-11 10:04:43') + 300 -  strftime('%s',
'2017-10-11 10:04:43')) < 0;


on SQlite 2.8, the operator < with strftime('%s') works.

Any idea if it is the expected behavior?


Best Regards,

sqlite-users mailing list
sqlite-users mailing list

Reply via email to