Código PHP:
$_dia = date(j);
$_mes = date(n);
$_anyo = date(Y);
$result=mssql_query("select Referencia,Lote,Peso,dia,mes,anyo from _Pintura_ELECQUI order by referencia") or die("error de secuencia SQL");
while($row = mssql_fetch_array($result))
{
$total = $total + $row[2];
$dia = intval($row[3]);
$mes = intval($row[4]);
$anyo = intval($row[5]);
if (($anyo <= $_anyo ) && ($mes <=$_mes ) &&($dia <=$_dia))
{
$this->SetTextColor(255,0,0);
$this->Cell(45,7,$row[0],0,0,'L');
$this->Cell(45,7,$row[1],0,0,'C');
$this->Cell(45,7,$row[2],0,0,'C');
$this->Cell(45,7,$dia."/".$mes."/".$anyo,0,0,'C');//substr($row[3],0,11)
$this->Ln();
} else {
$this->SetTextColor(0,0,0);
$this->Cell(45,7,$row[0],0,0,'L');
$this->Cell(45,7,$row[1],0,0,'C');
$this->Cell(45,7,$row[2],0,0,'C');
$this->Cell(45,7,$dia."/".$mes."/".$anyo,0,0,'C');//substr($row[3],0,11)
$this->Ln();
}