[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 363
  • Last Modified:

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
0
MRPT
Asked:
MRPT
  • 2
1 Solution
 
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
 
Gerwin Jansen, EE MVETopic 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
 
MRPTAuthor Commented:
Works as wanted, thank you.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now