MySQL Forums
Forum List  »  CSV Storage Engine

load data date fields
Posted by: New eba
Date: January 07, 2009 07:28PM

Please help me with syntax to load date format data as below.

table
+-------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| name | varchar(10) | YES | | NULL | |
| dte | date | YES | | NULL | |
+-------+-------------+------+-----+---------+-------+

data file

aaa, 5-Jan-2009
aaa, 5-Feb-2009

what should i do to load this data into mysql table.

i am using below command/syntax but its loading all in this format.

LOAD DATA INFILE '/tmp/ld.txt' INTO TABLE test1 FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n';
(name,@dte)
SET dte = (str_to_date(@dte, '%d-%m-%y');

MySql> select * from test1;
+------+------------+
| name | dte |
+------+------------+
| aaa | 0000-00-00 |
| aaa | 0000-00-00 |


I want date to be in 2008-01-05 format, Please help me.

Options: ReplyQuote


Subject
Views
Written By
Posted
load data date fields
13232
January 07, 2009 07:28PM
5824
January 07, 2009 07:30PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.