Import different type date from csv
Posted: Sun Apr 08, 2012 11:52 am
Hello, guys
I try to import date from csv file like dd.mm.yyyy in my mysql database and the date in csv file is dd/mm/yyyy. How to convert data? This is my code:
I try to import date from csv file like dd.mm.yyyy in my mysql database and the date in csv file is dd/mm/yyyy. How to convert data? This is my code:
Code: Select all
<?php header("Content-Type: text/html; charset=utf8_unicode"); ?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf8_unicode" />
</head>
<body>
<?php
$connec = mysql_connect('localhost','****','***');
mysql_select_db('export_ajur', $connec);
$sql = "LOAD DATA LOCAL INFILE 'purchase_invoice.csv'
INTO TABLE invoice
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"'
LINES TERMINATED BY '\r\n'
IGNORE 1 LINES
";
mysql_query($sql);
if(mysql_error()) {
echo(mysql_error());
} else {
echo("Import sucessfull data imported to mysql table.");
}
?>