Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 567
kannan Avatar asked Jun 06 '13 08:06

kannan


1 Answers

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
like image 53
sanjeev Avatar answered Sep 23 '22 03:09

sanjeev