Zend 1.12:如何在SQL选择时格式化日期

This question may be in part a duplicate of How to convert the system date format to dd/mm/yy in SQL Server 2008 R2?, but I could not get any of the answers there working in my code. We're using MySQL 5.0.95, I don't know if that makes a difference, but I couldn't find a definitive answer that solved my problem.

Here's my code:

public function getZipCodes() {
    // get records
    $select = new Zend_Db_Select($this->db);
    $select->from('postal_codes AS p', array(
            'p.postal_code',
            'p.city',
            'p.county',
            'p.area_codes',
            's.rate',
            // convert from datetime to mm/dd/yyyy format <== problem here
            'CONVERT(varchar(11), s.date, 101)'))
           ->joinInner('sales_surtax_rates AS s', 'p.county = s.county', array())
           ->where('p.state = "FL"')
           ->order('p.postal_code');

    $zip_codes = $this->db->fetchAll($select);

    Zend_Debug::dump($zip_codes);
    die();
}

I get a syntax error when trying to convert the datetime to a formatted string. I'm just not seeing what I'm missing, and other methods like FORMAT and cast didn't work for me either.

I'm well aware I can just loop through and reformat the datetime via PHP for each array item after pulling the records from the database, but I'm just trying to avoid the extra step(s) if I can and learn something new in the process.

You're using MSSQL syntax, it would appear, NOT MySQL's.

Try

DATE_FORMAT(s.date, '%m/%d/%Y')

instead.

Relevant docs: http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_date-format