0
I have the following column in oracle
DATA_FILTRO
01/04/2017 10:27:15
I would like to compare the month and year:
SELECT DATA_FILTRO
FROM TABELA
WHERE TO_CHAR(DATA_FILTRO,'MM/YYYY') ='04/2017'
In PLSQL works, but in PHP gives error
oci_execute(): ORA-01843: not a valid month in
PHP code
public function metodo($data){
$conn = new ConnectionFactory();
$con = $conn->getConnection();
$query = "SELECT DATA_FILTRO
FROM TABELA
WHERE TO_CHAR(DATA_FILTRO,'MM/YYYY') ='04/2017'";
$stmt = ociparse($con, $query);
oci_execute($stmt);
while ($row = oci_fetch_array($stmt, OCI_ASSOC)){
echo $row['DATA_FILTRO'];
}
$conn->closeConnection($con);
return $protocoloList;
}catch ( PDOException $ex ){ echo "Erro: ".$ex->getMessage(); }
}
In PHP Only works if it’s the month 05/2017
$query = "SELECT DATA_FILTRO FROM TABLE WHERE TRUNC(DATA_FILTRO,'MM') = TO_DATE('01/'|| '04/2017','DD/MM/YYYY')"?
– Don't Panic
continues the error
– adventistaam
https://forum.imasters.com.br/topic/447692-data-oracle-x-php/ .
– Motta