doctrine2 - how to get the date from a datetime register in doctrine? -


im using codeigniter doctrine, bd:

id fecha_publicacion 1  2013-03-23 14:52:06 2  2013-03-23 18:02:06 3  2013-03-23 00:00:00 ..   ... 

what want do, search publications date or between range of dates

the thing that, if want select fields date 2013-03-23 query returns 3erd field (which time 00:00:00)

how can want? i've tried many things had no success

public function postsbydates($tipo,$fecha1,$fecha2=''){     if($fecha2 == ''){         $fecha2 = $fecha1;     }      $this->qb = $this->em->createquerybuilder();     $this->qb->select('p')     ->from('models\post', 'p')     ->where(         $this->qb->expr()->eq('p.tipo', '?1'),         $this->qb->expr()->between('p.fecha_publicacion', '?2', '?3')             )        ->setparameter(1, $tipo)     ->setparameter(2, "$fecha1%")     ->setparameter(3, "$fecha2%");      $query = $this->qb->getquery();     $obj = $query->getresult();      return $obj; } 

the problem supplying date datetime/timestamp comparison. guessing converts supplied date (2013-03-23) timestamp (2013-3-23 00:00:00).

quick fix: can have 2 dates "2013-03-23 00:00:00" , "2013-03-23 23:59:59".

good solution: dql native query call mysql's date() function convert timestamp field (fecha_publicacion) date. after able use between function.


Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -