How to select data between two dates from sqlite d

2019-04-06 12:44发布

i have date column in my database in dd-mm-yyyy format.

i want to search the data between two dates.

i tried

SELECT * FROM t_data where orderdate between '01-05-2012 00:00:00' and '31-05-2012 23:59:59'

and

SELECT * FROM t_data where orderdate >= '05-05-2012' and  orderdate <='31-05-2012'

How to resolve this issue?

2条回答
手持菜刀,她持情操
2楼-- · 2019-04-06 13:00

The date format must be YYYY-MM-DD in SQLite.

查看更多
We Are One
3楼-- · 2019-04-06 13:01

use :

select * from tbl_name where Attribute_name between 'yyyy-mm-dd' and 'yyyy-mm-dd';

here Attribute_name is date_time column name

example :

select * from tbl_node where mydate between '2014-02-02' and '2014-02-06';

1|1|123|456|12eb-ab|1|1|254|123|19|2014-02-03 16:00:44
2|1|123|456|12eb-ab|1|1|254|123|19|2014-02-03 16:01:03
3|1|123|456|12eb-ab|1|1|254|123|19|2014-02-03 16:00:57
查看更多
登录 后发表回答