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
Solved

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

Posted on 2014-11-23
1
475 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
1 Comment
 
LVL 34

Accepted Solution

by:
johnsone earned 500 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Creation date for a PDB 5 39
Create file system directory from Oracle 10g 4 25
Database Design Dilemma 6 58
update using pipeline function 3 21
Subquery in Oracle: Sub queries are one of advance queries in oracle. Types of advance queries: •      Sub Queries •      Hierarchical Queries •      Set Operators Sub queries are know as the query called from another query or another subquery. It can …
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…

839 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