Update only the minute, second, millisecond... on an Oracle timestamp column

I have a timestamp column on an 11g DB which, due to a coding error which has since been fixed, caused the minute, second, millisecond... to be included instead of just "00". For example,

10/7/2018 02:03:02.432000 AM

What I need is to update all of these records which have a minute, second, millisecond greater than "00" to be "00"

e.g. 10/7/2018 02:00:00.000000 AM

I've played around with the extract() function, but I just can't figure out the correct syntax.

Thanks,
Larry
Larry GrovesAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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.

Kent OlsenDBACommented:
Hi Larry,

I read your statement as you want to drop the seconds and milliseconds, but your example drops the minute, too.

select systimestamp, trunc(systimestamp, 'MI') from dual;

That's an easy way to truncate the seconds and milliseconds.


Kent
0
Larry GrovesAuthor Commented:
Hi Kent,

Thanks for the reply.

I actually want to update the minute, second, millisecond to "0".

For example, let's say the current timestamp is 10/7/2018 02:03:02.432000 AM

pseudo:
update order set timecreated = 10/7/2018 02:00:00.000000 AM
where ...;

BTW. Sorry about that. I just updated my initial question and added the minute.

Thanks,
Larry
0
Kent OlsenDBACommented:
Easy enough.  :)  Just change the unit in the call to trunc().

  select systimestamp, trunc(systimestamp, 'HH') from dual;
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
Larry GrovesAuthor Commented:
I guess you're right. That was easy.

Overthinking... The art of creating problems that weren't even there.

Thanks Kent! I really appreciate your help.

Thanks,
Larry
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
SQL

From novice to tech pro — start learning today.