此查询正常工作:
$sql = "SELECT *
FROM `pricing_data`
WHERE `Label`='BTC'
AND `Timestamp` LIKE '2018-01-19 00:00:%'
LIMIT 1" ;
但这不是:
$date = date("Y-m-d ",strtotime("-1 days", time()))." 00:00:";
$to = "BTC" ;
$sql = "SELECT *
FROM `pricing_data`
WHERE `Label`='$to'
AND `Timestamp` LIKE '$date%'
LIMIT 1" ;
任何解决方案?
感谢。
答案 0 :(得分:1)
错误太小,无法查看
public ActionResult MyMethod([System.Web.Http.FromBody] MyModel model)
{
if (module.Fields == null && !string.IsNullOrEmpty(Request.Form["fields"]))
{
model.Fields = JsonConvert.DeserializeObject<MyFieldModel[]>(Request.Form["fields"]);
}
//... more code
}
中有一个额外的空格,因为在你创建的DateTime中创建了两个空格并且查询没有用。
Y-m-d
检查此输出以获得更多说明: - https://eval.in/939013
注意: - 不要手动添加小时和分钟,而是使用$date = date("Y-m-d",strtotime("-1 days", time()))." 00:00:";
//..................^ remove space from here --------^ already have here
本身,如下所示: -
所以最后代码必须是: -
date()