I need to change the time part of a datetime in a database.
What I got is in the database: '2010-01-01 01:00:00' I need to update this to '2010-01-01 03:00:00' Only thing I have is '03:00:00'
As I'm using doctrine I could iterate through all objects but this would decrease the perfomance. So what I tried was:
$q = Doctrine_Query::create()
->update('Something s')
->set('start_at', 'DATEADD(DATESUB(start_at,HOUR_SECOND TIME(start_at)), HOUR_SECOND ?)', $doctrine_article->start_time)
->set('start_at', 'DATEADD(DATESUB(end_at,HOUR_SECOND TIME(end_at)), HOUR_SECOND ?)', $doctrine_article->end_time)
->where('s.some_id = ?',$doctrine_article->id)
->andWhere('s.start_at > ?',$current_date)
->execute();
(update)
To explain a bit more:
I tried to remove the time part of the current Datetime, so I get '2010-01-01 00:00:00' and then add to this the given time ('03:00:00') so at the end it should be the wanted '2010-01-01 03:00:00'
But this leads to an error (1064 You have an error in your SQL syntax
)
Any hints how to solve this error and achieve the described functionality?