Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesOracle Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old April 2nd, 2008, 03:37 PM
2chocky 2chocky is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 6 2chocky User rank is Private First Class (20 - 50 Reputation Level)2chocky User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 45 m 23 sec
Reputation Power: 0
Combining dates

hi friends,

I am new to PL/SQL.
I need to migrate the data from old to new database.
In the old database i have table t_emp

create table t_emp(
EMP_YYYY VARCHAR2(4 BYTE),
EMP_MM VARCHAR2(2 BYTE),
EMP_DD VARCHAR2(2 BYTE),
EMP_HH VARCHAR2(2 BYTE),
EMP_TIME_MN VARCHAR2(2 BYTE),
EMP_TIME_SS VARCHAR2(2 BYTE),
EMP_TIME_HS VARCHAR2(2 BYTE),
EMP_NO);

ex:
1998 02 23 12 01 29

now i have one more new table in new database which contains

Create table t_emp_new
(start_date date);

i need to load all the old historical data into new table using PL/SQL.
How can i combine YYYY,MM,DD,HH,MN,SS,HS and insert as a single date.

02:23:1998 12:01:29


please help me regading this.


chockey

Reply With Quote
  #2  
Old April 2nd, 2008, 04:09 PM
pabloj's Avatar
pabloj pabloj is offline
Modding: Oracle MsSQL Firebird
Dev Shed God 6th Plane (7500 - 7999 posts)
 
Join Date: Jun 2001
Location: Outside US
Posts: 7,711 pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Months 2 Weeks 6 Days 5 h 22 m 58 sec
Reputation Power: 259
Concatenate and then cast as date with to_date() function, something like
sql Code:
Original - sql Code
  1. INSERT INTO
  2.  t_emp_new (start_date, emp_no)
  3. SELECT
  4.  to_date(EMP_YYYY || EMP_MM || EMP_DD, , 'yyyymmdd'),
  5.  emp_no
  6. FROM
  7.  t_emp
(example doesn't take into account the time part ) compliment to the genius who decided to split the date into many varchar fields ... and no need to prepend a t to tables and a v to views, the database knows the difference and it's willing to tell it to you with it's metadata

Reply With Quote
  #3  
Old April 4th, 2008, 01:18 PM
2chocky 2chocky is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 6 2chocky User rank is Private First Class (20 - 50 Reputation Level)2chocky User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 45 m 23 sec
Reputation Power: 0
Unhappy Hey thank u so much

Thank you so much.
i got it...
Comments on this post
pabloj agrees: Glad you got it!!!

Reply With Quote
  #4  
Old April 9th, 2008, 02:09 PM
2chocky 2chocky is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 6 2chocky User rank is Private First Class (20 - 50 Reputation Level)2chocky User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 45 m 23 sec
Reputation Power: 0
Hey,

Hey,

How can i get total date format

Ex:
4/9/2008 2:16:54 PM

In the above example i am able to get DDMMYYYY.
In the old database HS is the hunderads od seconds.

How can i combine hh:mi:ss with date????When i try to concatenate all hh,mi,ss i am getting only date DDMMYYYY


Thank you
chockey

Reply With Quote
  #5  
Old April 10th, 2008, 02:37 AM
pabloj's Avatar
pabloj pabloj is offline
Modding: Oracle MsSQL Firebird
Dev Shed God 6th Plane (7500 - 7999 posts)
 
Join Date: Jun 2001
Location: Outside US
Posts: 7,711 pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Months 2 Weeks 6 Days 5 h 22 m 58 sec
Reputation Power: 259
Show us the actual query

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > Combining dates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway