select between two dates ms access using php -
i want select data ms access using php here code :
$dbdir = "d:\payroll2\att2000.mdb"; $conn = odbc_connect("driver=microsoft access driver (*.mdb);dbq=$dbdir", "administrator", ""); $b = 4104; $jo = date('n/j/y h:i:s a',strtotime('2016-01-21 00:00:01')); $ji = date('n/j/y h:i:s a',strtotime('2016-01-21 23:59:59')); $sql = "select top 20 * checkinout inner join userinfo on checkinout.userid = userinfo.userid userinfo.ssn = '$b'"; $rs = odbc_exec($conn,$sql); odbc_fetch_row($rs, 0); while (odbc_fetch_row($rs)) { echo odbc_result($rs,"checktime"); print('<br>'); } odbc_close($conn); }
it works fine , want select data between 2 dates add and checkinout.checktime between '$jo' , '$ji'
query :
$sql = "select top 20 * checkinout inner join userinfo on checkinout.userid = userinfo.userid userinfo.ssn = '$b' , checkinout.checktime between '$jo' , '$ji'";
i dont know why doest work, im sure data exist , date format persist ms access date format.
any appreciated, im sorry bad english..
with msaccess & ms sql server believe need use hash signs around dates , might need use cdate()
ensure date recognised date.
$sql = "select top 20 * checkinout inner join userinfo on checkinout.userid = userinfo.userid userinfo.ssn = '$b' , cdate( checkinout.checktime ) between '#{$jo}#' , '#{$ji}#'";
Comments
Post a Comment