為什么我在 Microsoft Access odbc_exec() 中查詢“CONVERT”:SQL 錯誤:[Microsoft][ODBC Microsoft Access Driver] 運算式中未定義函式“CONVERT”。
這是我的查詢

<?php
// setup database for your microsoft Access
// you can setup password in you microsoft Access
// this is a variable for your connection in odbc
// "zkConnection" is your ODBC Data Source Administrator
$conn = odbc_connect("zkConnection", "", "");
// create condition for testing conecction
if ($conn) {
// echo "<br>Connection Established</br>";
} else {
echo "Koneksi Gagal";
}
$from_date = $_REQUEST['from_date'];
$to_date = $_REQUEST['to_date'];
$query = "INSERT INTO CalculateData(USERID, Name, lastname, CardNo, DEPTID, DEPTNAME, SUPDEPTID, datein, timein, dateout, timeout)
SELECT USERID, Name, lastname, CardNo, DEPTID, DEPTNAME, SUPDEPTID, CONVERT(date, CHECKTIME) AS datein, MIN(CHECKTIME) AS timein, CONVERT(date, CHECKTIME) AS dateout, MAX(CHECKTIME) AS timeout
FROM TransactionLog
WHERE CHECKTIME BETWEEN #$from_date# AND #$to_date#
GROUP BY USERID, Name, lastname, CardNo, DEPTID, DEPTNAME, SUPDEPTID, CONVERT(date, CHECKTIME)";
$letsgo = odbc_exec($conn, $query);
if ($letsgo === false)
{
die(print_r( odbc_error(), true));
}
header("location: index.php");
?>
這個解決方案有什么想法嗎?
uj5u.com熱心網友回復:
CONVERTAccess SQL 中沒有這樣的東西。
相反,每個轉換有一個單獨的功能,例如CDate,CInt,CStr等。
CONVERT(date, 與交換CDate(。請注意,Access 中的日期轉換假定為 yyyy-mm-dd 或 mm/dd/yyyy。
有關轉換函式的完整串列,請參閱https://docs.microsoft.com/en-us/office/vba/language/concepts/getting-started/type-conversion-functions。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/314239.html
