Sir I have these codes
$last_date="";
$last_vno="";
$queryx = "SELECT MAX(t1.date)as mxdate,MAX(t1.vou_no)as mxvno,max(d1)as d1
FROM vouchers t1
WHERE t1.date = (SELECT MAX(t2.date)as date FROM vouchers t2 where vou_type='CP' and dr_amount>0)";
$resultx=sqlsrv_query($con,$queryx)or die("Error". sqlsrv_errors($con)) ;
if ($resultx){
while ($rowx = sqlsrv_fetch_array ($resultx)){
$last_date=$rowx['mxdate'];
$last_vno=$rowx['mxvno'];
$myparty=$rowx['d1'];
}
}else{
echo "no data found";
exit;
}
The query work fine, no issue
nOW i want to use $last_date in an other qeury like this
$query = "SELECT * FROM vouchers where vou_type = 'CP' and date='".$last_date."' and vou_no='".$last_vno."'";
but it says:
Catchable fatal error: Object of class DateTime could not be converted to string in ...
Please help