this thing happens only in localhost
A Database Error Occurred
Error Number: 1064
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'GETDATE())' at line 1
SELECT MAX(RIGHT(DaftarNomor,2)) AS kd_max FROM TDaftarTelepon_Coba WHERE DaftarTanggal= CONVERT(date,GETDATE())
Filename: C:/xampp/htdocs/daftarpasien/system/database/DB_driver.php Line Number: 691
here is my code:
$date= date("Y-m-d");
$kodeunit = $this->input->post('UnitKode');
$q = $this->db->query("SELECT MAX(RIGHT(DaftarNomor,2)) AS kd_max FROM TDaftarTelepon_Coba WHERE DaftarTanggal= CONVERT(date,GETDATE())");
$kd = "";
if ($q->num_rows() > 0) {
foreach ($q->result() as $k) {
$tmp = ((int)$k->kd_max) 1;
$kd = sprintf("s", $tmp);
}
} else {
$kd = "01";
}
CodePudding user response:
You should use the DATE()
function to get a timestamp date:
$q = $this->db->query("
SELECT
MAX(RIGHT(DaftarNomor,2)) AS kd_max
FROM
TDaftarTelepon_Coba
WHERE
DaftarTanggal = DATE(date)
");