Update a column

Hi,
I have a column with DATE datatype and has data in it.
Based on this column, I would like to update another column that is of NUMBER datatype.
The data should be updated as follows:

source_column: 01-JAN-2013
target_column: 20130101 (YYYYMMDD format)

Could someone please suggest?

Thanks
MRPTAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Gerwin Jansen, EE MVEConnect With a Mentor Topic Advisor Commented:
And if it looks OK, update like this:

update your_table
set target_column = to_number(to_char(trunc(source_column),'YYYYMMDD'));
0
 
Gerwin Jansen, EE MVETopic Advisor Commented:
Try this:

select to_number(to_char(trunc(source_column),'YYYYMMDD'))
from your_table;

(to see if you get the right values).
0
 
MRPTAuthor Commented:
Works as wanted, thank you.
0
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.

All Courses

From novice to tech pro — start learning today.