Page 1 of 1

dbase date format

Posted: Wed Feb 13, 2008 11:22 am
by bouncer
hi there.

when i get a record from a date field in a .dbf file is like this yyyymmdd, is there anyway to get it like this, yyyy-mm-dd ?

thanks in advance

Re: dbase date format

Posted: Wed Feb 13, 2008 11:34 am
by Zoxive
http://dev.mysql.com/doc/refman/5.0/en/ ... ate-format

Code: Select all

SELECT DATE_FORMAT(mydatefld,'%Y-%m-%d') AS date FROM `stuff`

Re: dbase date format

Posted: Wed Feb 13, 2008 12:45 pm
by bouncer
i'm reading a .dbf file, so i think that doesn't work.

Code: Select all

 
$dbase = dbase_open('sys_inf.dbf', 0) or die (error());
$record_numbers = dbase_numrecords( $dbase);
    for ($i = 1; $i <= $record_numbers; $i++) {
        $row = dbase_get_record_with_names($dbase, $i);
        echo $row['SYSDATE'];     // ---> 20070910  and i need, 2007-09-10
    }
dbase_close( $dbase );
 
thanks in advance

Re: dbase date format

Posted: Wed Feb 13, 2008 1:10 pm
by Zoxive

Code: Select all

$row['SYSDATE'] = date('Y-m-d',strotime($row['SYSDATE'];));

Re: dbase date format

Posted: Fri Feb 15, 2008 8:40 am
by bouncer
thanks, that solve my problem. :D

regards