Update Only Date

I have a table with column datetime which has value as follows

31/03/2011 11:59:00 PM

Without distrubing the time, I only want to change the date portion as 31/12/2020

how do i do this
GRChandrashekarAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Naveen KumarProduction Manager / Application Support ManagerCommented:
try this :

update your_table
set date_column = to_date( '31-Dec-2020' || to_char(date_column,'HH:MI:SS AM'),
'dd-Mon-yyyy HH:MI:SS AM')
where <<use accordingly >>>;
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
johanntagleCommented:
update table_name set date_column = date_column + (to_date('31-12-2020','DD-MM-YYYY') - to_date('31-03-2011','DD-MM-YYYY'))

The expression after the plus sign just gets the number of days between the two dates, which is then added to your date_column.  You will be adding whole days, so the time should not change.
0
johanntagleCommented:
oh yes of course you need to add a where clause.
0
PilouteCommented:
Hi,

update <you table name> a
set a.<date column name>=to_date((
select '31/12/2020 ' ||  to_char(b.<date column name>,'HH:MI:SS')
from <you table name> b where a.<key column(s)>=b.<key column(s)>
),'DD/MM/YYYY HH:MI:SS');

Cheers,
P
0
Naveen KumarProduction Manager / Application Support ManagerCommented:
Good and thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.