We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

not valid month in Oracle

Good morning. I'm keeping a record. I'm turning date variables to the correct format Oracle But I get error

    $fechanacimiento = DateTime::createFromFormat('Y-m-d', $this->request->getPost("CONT_FECNACI"));
    echo $fechanacimiento->format('d/m/Y');
    $SPM_CONTACTO = new SpmContacto();
    $SPM_CONTACTO->CONT_CODIGO = $this->request->getPost("CONT_CODIGO");
    $SPM_CONTACTO->CONT_CEDULA = $this->request->getPost("CONT_CEDULA");
    $SPM_CONTACTO->CONT_RUCIDE = $this->request->getPost("CONT_RUCIDE");
    $SPM_CONTACTO->CONT_NOMBRE = $this->request->getPost("CONT_NOMBRE");
    $SPM_CONTACTO->CONT_FECNACI = $fechanacimiento->format('d/m/Y');
    $SPM_CONTACTO->CONT_FECINSC = $fechainscripcion->format('d/m/Y');
    $SPM_CONTACTO->CONT_TIPOCODIGO = $this->request->getPost("CONT_TIPOCODIGO");

SQLSTATE[HY000]: General error: 1843 OCIStmtExecute: ORA-01843: not a valid month (/tmp/pear/download/PDO_OCI-1.0/oci_statement.c:142)

The result of the "echo" is '26/04/2016'.That I was wrong



81.2k

I think Phalcon uses this column as a string and not as a date

edited Apr '16

How it's related to phalcon ? You just see that you have error in oracle, not from phalcon.

my guess is that database you have column configured in that way that it expects month on first occurene or as last so both 26 or 2016 is wrong month



81.2k

I already check the configuration. The date is correct. Or use an insert to a simple sql. I've tried the date types, datetime, timestamp. I think at some point, the value date changes to type string. I returned to create the model

class SpmContacto extends \Phalcon\Mvc\Model{
public $CONT_FECNACI;
/** *
 * @var string
 */
public $CONT_FECINSC;
/***
 * @var string
 */

At the time of creating this comment is created as type string