I am trying to retrieve all rows that were inserted today (only DATE, not time) in my mysql db.
$query = $em->createQuery("SELECT md
FROM YtBundle:Mood md
WHERE md.created_at = CURRENT_DATE()
");
$moods = $query->getResult();
I have inserted a test row created at 2013-04-24 02:00:00 and unfortunately I get no results. If I change "=" with ">" it successfully works OK. Any idea about why is this happening ? It appears that all entries inserted in today's date have a +1 difference after running the query.
What about :
$query = $em->createQuery("SELECT md
FROM YtBundle:Mood md
WHERE md.created_at >= CURRENT_DATE()
");
$moods = $query->getResult();
Column created_at is stored in a TIMESTAMP column so CURRENT_DATE = '2013-04-24 00:00:00', and it's not equal to '2013-04-24 02:00:00'