SQL Loader

Received a text file and three fields are Date, but the data sent as follows :
20151014T1028

How can I import only the date and time and ignore the 'T' ? at least the date without time .

Using Oracle 8i

Thank you
m_jundiAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

johnsoneSenior Oracle DBACommented:
I don't have a 8 database that I can test this on, but it should work.  Date format models allow for character literals in them.  They need to be enclosed in double quotes.  So your date format should look something like this:

yyyymmdd"T"hh24:mi

Give it a try:

select to_date('20151014T1028','yyyymmdd"T"hh24:mi') from dual;

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
awking00Information Technology SpecialistCommented:
Example control file showing to_date function on load. Note - yourdtfield must be date datatype on yourtable
LOAD DATA
INSERT INTO TABLE yourtable
...
(
...
yourdtfield "TO_DATE(:yourdtfield,'yyyymmdd"T"hh24:mi')"
...
)
m_jundiAuthor Commented:
1) SQL*Loader-350: Syntax error at line 12.
Expecting "," or ")", found "(".
TO_DATE(EXTRACT_DATE,'yyyymmdd"T"hh24:mi'),

2)SQL*Loader-350: Syntax error at line 12.
Expecting "," or ")", found "T".
EXTRACT_DATE "TO_DATE(:EXTRACT_DATE,'yyyymmdd"T"hh24:mi')",

My Control File :
LOAD DATA
INFILE 'c:\order.txt'
INTO TABLE ORDERS
fields terminated by '|'
TRAILING NULLCOLS
(ITEM,
NAME,
EXTRACT_DATE "TO_DATE(:EXTRACT_DATE,'yyyymmdd"T"hh24:mi')",
DELIVER_MODE_CODE)
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

johnsoneSenior Oracle DBACommented:
You have double quotes inside of double quotes.  You need to escape them.  The line in your control file should be:

EXTRACT_DATE "TO_DATE(:EXTRACT_DATE,'yyyymmdd\"T\"hh24:mi')",
m_jundiAuthor Commented:
Also got an error :

SQL*Loader-350: Syntax error at line 12.
Expecting "," or ")", found "T".
EXTRACT_DATE "TO_DATE(:EXTRACT_DATE,'yyyymmdd\"T\"hh24:mi')",

Anyhow I was able to extract the date only using this :
EXTRACT_DATE "to_date(substr(replace(:EXTRACT_DATE,'T',' '),1,13),'YYYYMMDD HH24:MI')"
johnsoneSenior Oracle DBACommented:
Odd.  It worked fine for me.  Here is my control file:
LOAD DATA
	INFILE *
	DISCARDMAX 9999
	APPEND INTO TABLE mytab
	fields terminated by "	"
	trailing NULLCOLS
	(
		EXTRACT_DATE "TO_DATE(:extract_date,'yyyymmdd\"T\"hh24:mi')"
	)
BEGINDATA
20151014T1028

Open in new window

Just created a simple table with:
CREATE TABLE mytab 
  ( 
     extract_date DATE 
  ); 

Open in new window

Then loaded using SQL*Loader.  No problems, loaded just fine.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.