?
Solved

How to Cast VARCHAR2 to TIMESTAMP(6) In Select Statement In Oracle?

Posted on 2014-11-23
1
Medium Priority
?
505 Views
Last Modified: 2014-11-23
Dear Experts,

I have a table with a field varchar2(24) with values like: '2012-09-27 01:40:31.0' (I think trailing spaces exist as well)

I want to perform insert into table select that field but the corresponding field in the target table is type TIMESTAMP(6)

How can I achieve this?

BR
0
Comment
Question by:GurcanK
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 35

Accepted Solution

by:
johnsone earned 2000 total points
ID: 40460567
You just need to include a to_timestamp function on the character field.

insert into mytab (col1) select to_timestamp(col2, 'yyyy-mm-dd hh24:mi:ss.ff') from mytab;

If for any reason a value is not in that specific format, you will get an error.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that useā€¦
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
This video shows how to recover a database from a user managed backup
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question