我试图使用PHP和SQLSRV从SQL Server中检索数据,但得到了错误。
[Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Conversion failed when converting date andor time from character string. [信息] => [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Conversion failed when converting date andor time from character string.
谁能帮我解决这里的问题。谢谢你的帮助
<?php
if(isset($_POST['update'])) {
require_once('connection.php');
$recorded_on = $_POST['recorded_on'];
$recorded_end = $_POST['recorded_on'];
//$pin = $_POST['pin'];
$sql = "
SELECT *
FROM dbo.activity_logs
WHERE recorded_on between '.$recorded_on.' and '.$recorded_end.'
";
你也可以试试
require_once('connection.php');
$recorded_on = date('Y-m-d',strtotime($_POST['recorded_on']));
$recorded_end = date('Y-m-d',strtotime($_POST['recorded_on']));
//$pin = $_POST['pin'];
$sql = "
SELECT *
FROM dbo.activity_logs
WHERE DATE(recorded_on) between '".$recorded_on."' and '".$recorded_end."'
";