0

I've got table with column of type date. In my script, I generate date array as follows :

$date2 = date('Y-d-m', strtotime($date2));
for ($i = 0; $i <= 7; $i++)
{
    $date1 = str_replace('-', '/', $date2);
    $tomorrow = date('Y-d-m',strtotime($date1 . "+".$i." days"));

    echo 'counted date : '.$tomorrow.PHP_EOL ;
    array_push($dates, $tomorrow);
}

And got the following output :

counted date : 2016-01-08
counted date : 2016-02-08
counted date : 2016-03-08
counted date : 2016-04-08
counted date : 2016-05-08
counted date : 2016-06-08
counted date : 2016-07-08
counted date : 2016-08-08

I also got Phalcon expression :

$status1 = $app
    ->modelsManager
    ->executeQuery("
        SELECT * 
          FROM MastersFullTime 
         WHERE MastersFullTime.date = :date:
           AND MastersFullTime.master_id = :master_id:"
        ,
        array(
            'date' => $date , 
            'master_id' => $master_id
        )
    );

But WHERE MastersFullTime.date = :date: not working. How can I compare date objects? Thanks in advance!

Martin
  • 22,212
  • 11
  • 70
  • 132
Nikita Semenov
  • 2,111
  • 4
  • 18
  • 31
  • 1
    Could it be the extra `:` at the end of this line `:master_id:` – RiggsFolly Aug 01 '16 at 14:50
  • 1
    Dateformat should be `y-m-d` – Jens Aug 01 '16 at 14:50
  • 2
    MYSQL stored dates in a logical format i.e. `Y-m-d` if you want to use odd date formats in your presentation logic all well ang good, but MYSQL will not understant dates unless they conform to its requirements. I thought the American date format was illogical enough, but this one beats all – RiggsFolly Aug 01 '16 at 14:52
  • @Jens , RiggsFolly - that's it! Thanks! – Nikita Semenov Aug 01 '16 at 14:58

0 Answers0