='".$kstime."' and createdtime &"/> ='".$kstime."' and createdtime &">

Home >Backend Development >PHP Tutorial >php 日期搜索为什么不包括当天,该怎么处理

php 日期搜索为什么不包括当天,该怎么处理

WBOY
WBOYOriginal
2016-06-13 10:27:151170browse

php 日期搜索为什么不包括当天
sql语句是这样的:
$kstime=$_POST["kstime"];
$jstime=$_POST["jstime"];

Select * From tab where createdtime >='".$kstime."' and createdtime
搜索出来的结果为什么不包括当天的呢?当createdtime >='2012-6-7' and createdtime

------解决方案--------------------

探讨

createdtime >='2012-6-7 00:00:00' and createdtime
如果直接判断2012-6-7这样的话得用in

------解决方案--------------------
探讨
SQL code


#结果包含边界值
$sql = "SELECT * FROM tab WHERE createdtime BETWEEN '".$kstime."' AND '".$jstime."';"

------解决方案--------------------
Select * From tab where date_format(createdtime,'%Y-%m-%d') BETWEEN '2012-06-28' and '2012-06-30'
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn