sql - How to change time part of a datetime value with doctrine? -


i need change time part of datetime in database.

what got in database: '2010-01-01 01:00:00' need update '2010-01-01 03:00:00' thing have '03:00:00'

as i'm using doctrine iterate through objects decrease perfomance. 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)
explain bit more:
tried remove time part of current datetime, '2010-01-01 00:00:00' , add given time ('03:00:00') @ end should wanted '2010-01-01 03:00:00'

but leads error (1064 have error in sql syntax)

any hints how solve error , achieve described functionality?

it easier use date function remove time part. after that, can use different ways add time again:

start_at = date(start_at) + interval 3 hour  start_at = date(start_at) + interval 10800 second  start_at = concat(date(start_at), ' ', '03:00:00') 

and on.


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -