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 it works, however in PHP it 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 the month is 05/2017