473,385 Members | 1,320 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

importing data with date format

I have several files with data I would like to import into DB2, but I
have timestamps set in a format, which DB2 can't catch - DD-MM-YYYY
HH:MM:SS

DB2 wants to get the year first. Is there a way I can say that my data
is going to come in this format or do I need to convert it outside the
database?

--
Ewa
Jan 18 '08 #1
5 7952
E.************@gmail.com wrote:
I have several files with data I would like to import into DB2, but I
have timestamps set in a format, which DB2 can't catch - DD-MM-YYYY
HH:MM:SS

DB2 wants to get the year first. Is there a way I can say that my data
is going to come in this format or do I need to convert it outside the
database?
Which version of DB2?
You can load the data into a table with a generated column and let the
generated column convert the string into a timestamp.
Then you alter the generated column to a normal column and drop the
staging column.
Reorg.. done.

In DB2 9.5 for LUW the TIMESTAMP_FORMAT (aka TO_DATE) function can do
this conversion easily. Prior to DB2 9.5 you have to reshuffle the
timestamp string with substr and concat and then pass it into the
TIMESTAMP function

Of course you can always to a regular LOAD into a string column to a
staging table and then LOAD FROM CURSOR to the final table. Doing the
transformation in the cursor.

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Jan 18 '08 #2
I found what I was looking for in the DB2 Control Center where in the
import function I can define the date format which I have in my file,
but I have another problem now. During the import I get an error, that
says that the data in my first column and first row can't be converted
into an INTEGER. My data looks like this:
1,01-01-2007 00:00:00,S,0,30-10-2007 13:02:51:357,30-10-2007
13:02:51:357,inf39dl,inf39dl
2,02-01-2007 00:00:00,R,0,30-10-2007 13:02:51:387,30-10-2007
13:02:51:387,inf39dl,inf39dl
3,03-01-2007 00:00:00,R,0,30-10-2007 13:02:51:387,30-10-2007
13:02:51:387,inf39dl,inf39dl
Any ideas? Should the integer values be formatted in some special way?

Hmmm... I wonder... Just for kicks add a space after that first comma.
Maybe in your local a 1,01 is a decimal 1.01 ???
I'm guessing....
That was a long shot ;) Unfortunately that's not the case... I'm
getting another error that says something about not importing all of
the data after the 8 column (inf39dl) in the first row (and then the
same 2 errors for the rest od the rows in the file), so he gets all
the columns right and it's definitely a problem with the "1"... I just
can't get it...

--
Ewa
Jan 22 '08 #3
E.************@gmail.com wrote:
That was a long shot ;) Unfortunately that's not the case... I'm
getting another error that says something about not importing all of
the data after the 8 column (inf39dl) in the first row (and then the
same 2 errors for the rest od the rows in the file), so he gets all
the columns right and it's definitely a problem with the "1"... I just
can't get it...
Hmmm... while we're doing long shots:
1,01-01-2007 00:00:00,S,0,30-10-2007 13:02:51:357,30-10-2007
13:02:51:357,inf39dl,inf39dl
~~~~~~~~~~~~
This cannot be converted to integer. Wrapping of the message or a
problem in your file?

I think to help further we'd need to see the IMPORT statement ("show
SQL" in control center?) and the table definition.

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Jan 22 '08 #4
That was a long shot ;) Unfortunately that's not the case... I'm
getting another error that says something about not importing all of
the data after the 8 column (inf39dl) in the first row (and then the
same 2 errors for the rest od the rows in the file), so he gets all
the columns right and it's definitely a problem with the "1"... I just
can't get it...

Hmmm... while we're doing long shots:
1,01-01-2007 00:00:00,S,0,30-10-2007 13:02:51:357,30-10-2007
13:02:51:357,inf39dl,inf39dl
~~~~~~~~~~~~
This cannot be converted to integer. Wrapping of the message or a
problem in your file?
Sorry, wrapping...
I think to help further we'd need to see the IMPORT statement ("show
SQL" in control center?) and the table definition.

CONNECT TO DEVDB USER "devdb";
IMPORT FROM "C:\DB\dane.txt" OF DEL MODIFIED BY TIMESTAMPFORMAT="DD-MM-
YYYY HH:MM:SSTT" COLDEL, METHOD P (1, 2, 3, 4, 5, 6, 7, 8) MESSAGES "C:
\DB\komunikaty.txt" INSERT INTO DEVDB.KALENDARZ ("id_kalendarza",
"dzien_w_kalendarzu", "status_dnia", "id_typu_kalendarza",
"kiedy_utworzono", "kiedy_modyfikowano", "kto_modyfikował",
"kto_utworzył");
CONNECT RESET;

"id_kalendarza" INTEGER 4 Nie
"dzien_w_kalendarzu" TIMESTAMP 10 Nie
"status_dnia" CHARACTER 1 Nie
"id_typu_kalendarza" INTEGER 4 Nie
"kiedy_utworzono" TIMESTAMP 10 Nie
"kiedy_modyfikowano" TIMESTAMP 10 Nie
"kto_modyfikował" VARCHAR 16 Nie
"kto_utworzył" VARCHAR 16 Nie

I hope this will give a better picture (sorry for the polish names, I
didn`t have the inspiration to do the translating ;))

Thanks a lot for your help!

--
Ewa
Jan 23 '08 #5
I hope this will give a better picture (sorry for the polish names, I
didn`t have the inspiration to do the translating ;))
Found it!

It was an encoding problem... just figures...

Thanks a lot for all your help :)

--
Ewa
Jan 23 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Nathan Bloom | last post by:
Hi, I have a procedure that transfer data from an Excel spreadsheet to an Access 2000 table. There is a start date and an end date in the range specified. One of the date fields transfers...
2
by: TheElectron707 | last post by:
Hi! I have a scenario in which i am importing a VERY LARGE database over the network. (Linking is not my solution). Now it takes many hours to import the complete database. I want that once the...
9
by: Edward S | last post by:
I budget for a Project in an Excel sheet as illustrated below. The months below are usually a 2 year period i.e. 24 months, though it could be over 24 months depending upon a Project. I then...
7
by: Darren | last post by:
I have been attempting to create a reservation planning form in excel that imports Data from an Access database and inserts that information automaticly into the correct spreed sheet and the...
8
by: harry | last post by:
Hi Folks: I'm trying to do something that looks simple, but I can't make it work right. It's Access 2000 on a Win2000 computer. I create a database with 5 columbs. The data I need to import...
2
by: nutthatch | last post by:
I want to be able to import an Excel spreadsheet into Access 2K using the macro command Transferspreadsheet. However, the file I am importing (over which I have no control) contains some records...
9
by: jillandgordon | last post by:
I am trying to import an excel file into Access 97. It looks perfectly all right but, every time I try to import it, I get to the lst step and am told that it was not imported due to an error. ...
2
by: runway27 | last post by:
presently i have a table in which there are records and the fields are slno (this is a primary key auto increment), firstname, lastname, email, date(which inserts as a date format) these records are...
1
by: Sudhakar | last post by:
presently i have a table in which there are records and the fields are slno (this is a primary key auto increment), firstname, lastname, email, date(which inserts as a date format) these records...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.