Source language: Translate to:

Converting Dates between MySQL & Access

Questions about our Advanced Database plug-in

Moderator: Neosoft Support

Converting Dates between MySQL & Access

Postby David de Argentina » Wed Jul 23, 2014 12:35 pm

Hi all,

This is the scenario:

I have a remote MySQL database where all data is stored.
Each user has an MS-Access database that store his local data.
Data is generated via a PHP program and imported as CSV file.

I use this action to define the importation:

Code: Select all
dbpImportFromCSV "test" "Siniestros" "[TempDir]siniestros.txt" "[#34]Delimiter=;[#34];ContainsFieldNames=No;MatchFieldNames=No"


MySQL returns dates in YYYY-mm-dd format.
MS-Access does not recognize this format as Date-Time format.

Could any tell me how to convert this date values ?

Thanks in advance,
David de Argentina
User avatar
David de Argentina
 
Posts: 1553
Joined: Mon Apr 04, 2005 4:13 pm
Location: Buenos Aires, Argentina

Re: Converting Dates between MySQL & Access

Postby David de Argentina » Wed Jul 23, 2014 9:13 pm

Problem solved.

The PHP program that retrieves the data, has this lines to fetch the correct date format:

Syntax: [ Download ] [ Hide ]
Using PHP Syntax Highlighting
while ($fila = mysql_fetch_array($result, MYSQL_BOTH)) {
 $f1 = $fila["date"];
 $f2 = DateTime::createFromFormat('Y-m-d', $f1);
 $ff = date_format($f2, 'd/m/Y') . " 0:00:00";
 echo $fila["id"] . ";" . $fila["cia_id"] . ";" . $fila["oper_id"] . ";" . $fila["pax_id"] . ";" . $ff . ";" . $fila["city"] . ";" . $fila["country"] . ";" . $fila["type"] . ";" . $fila["subtype"] . ";" . $fila["work_id"] . "\r\n";
}
Parsed in 0.099 seconds, using GeSHi 1.0.8.10


David de Argentina
User avatar
David de Argentina
 
Posts: 1553
Joined: Mon Apr 04, 2005 4:13 pm
Location: Buenos Aires, Argentina


Return to NeoBookDBPro

Who is online

Users browsing this forum: No registered users and 0 guests

cron