I would like to know how to write a SQL query to select #from
and #to
any date within a MySql table. I know how to SELECT *FROM table
but struggle to know how to SELECT from
and to any dates so then a user would be able to select using a datepicker, this is code from my PHP also jQuery for the datepicker.
我想知道如何编写SQL查询来选择#from和#to在MySql表中的任何日期。我知道如何SELECT * FROM表,但很难知道如何从任何日期进行SELECT,以便用户可以选择使用datepicker,这是我的PHP代码,也是jQuery for datepicker。
$sql = "SELECT * FROM table WHERE time BETWEEN ('2015-00-00 00:00:00') AND ('2015-00-00 23:59:00')";
$( "#from" ).datepicker();
$( "#to" ).datepicker();
$( "#from" ).datepicker( "option", {dateFormat: 'dd-mm-yyT00:00:00'});
$( "#to" ).datepicker( "option", {dateFormat: 'dd-mm-yyT23:59:59'});
1 个解决方案
#1
1
You're almost there. Try this instead:
你快到了。试试这个:
SELECT * FROM `table` WHERE (time BETWEEN '2015-00-00 00:00:00' AND '2015-00-00 23:59:00')
Make sure you're using a DATETIME
field so MySQL can search efficiently.
确保您使用的是DATETIME字段,以便MySQL可以有效地进行搜索。
#1
1
You're almost there. Try this instead:
你快到了。试试这个:
SELECT * FROM `table` WHERE (time BETWEEN '2015-00-00 00:00:00' AND '2015-00-00 23:59:00')
Make sure you're using a DATETIME
field so MySQL can search efficiently.
确保您使用的是DATETIME字段,以便MySQL可以有效地进行搜索。