tags:

views:

51

answers:

1

So i need to update some dates on an Oracle Database, the field is a datetime, but i only want the date updated and leave the time as it is... There query goes like this:

update table 
   SET field = to_date('07312010','MMDDYY');

But it's overriding the hours, minutes and seconds from the field, i want to update the date but i want the hour to be left the same, any thoughts?

+8  A: 

You could use:

UPDATE TABLE
   SET field = TO_DATE('07312010' || ' ' || TO_CHAR(field, 'HH24:MI:SS'),
                       'MMDDYY HH24:MI:SS');
OMG Ponies
Thank you very much, this worked perfectly! :)
Gotjosh