Parthiv Shah
Parthiv Shah

Reputation: 360

SQLite3 DateTime comparison in linux

As per seen in image my first query return 5 rows but my second query does not return any rows. It shoud be return 3 rows.

enter image description here

I also have tried with Store my all datetime data in format of 'yyyy-MM-dd hh:mm:ss'

"SELECT billheaderid,billheadercode,billtotalitem,billtotalamount,createdby,createdon WHERE cretedon >= Datetime('2014-08-19 12:26:32')"

Upvotes: 0

Views: 60

Answers (2)

Pankaj Vavadiya
Pankaj Vavadiya

Reputation: 481

Store your data in form of 'yyyy-MM-dd hh:mm:ss'

And please care that '2014-08-19 03:45 PM' must be store as '2014-08-19 15:45:23' not as '2014-08-19 03:45:23'.

After that you don't need use datetime function. I am sure it'll work 100%.

Upvotes: 1

CL.
CL.

Reputation: 180070

Date values with "AM/PM" fields cannot be compared correctly with string comparisons (1 is larger than 0).

You have to change all the values in the database to the correct format yyyy-MM-dd hh:mm:ss. (And it is not necessary to call the datetime function.)

Upvotes: 1

Related Questions