How to select data between two dates from sqlite db in dd-mm-yyyy format?

允我心安 提交于 2019-12-12 08:39:09

问题


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?


回答1:


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



回答2:


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



来源:https://stackoverflow.com/questions/16957274/how-to-select-data-between-two-dates-from-sqlite-db-in-dd-mm-yyyy-format

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!