on 1/6/03 8:24 PM, David Chamberlin at [EMAIL PROTECTED] appended the
following bits to my mbox:

> Is there any way to set the time format so that any time values in my
> SELECT call are in a speicified format (e.g., HH:MM instead of HH:MM:SS).
> Basically I've got a table of a variety of different types, some of
> which are times.  I want to issue a select that retrieves all of the
> data for a row, and have any time values be returned in HH:MM (for example).
> I can (very painfully) go through all the results, figure out which ones
> are time values, and then do SELECT TIME_FORMAT() on each one of those,
> but that seems like a horrendous solution to a simple problem.

As John said, there's not a way (I know of) to just tell MySQL to display
times in a different format without the TIME_FORMAT calls.

Why not add the TIME_FORMAT calls to the original query rather than
performing all the extra queries?  Is your first select something like the


Even if you don't want to specify all the columns, you could add the
additional ones like this:

SELECT *,TIME_FORMAT(time_column_1,'%whatever') AS time_column_1 FROM table

If you are using a mysql_fetch_assoc function, giving the alias the same
name as the original column makes only the alias show up in your array.

If you don't know what all the time columns are, you could do a "SHOW
COLUMNS FROM table" query first, then use PHP to parse the results to tell
you which fields are time types, then use that result to build a query like
that above. (You could also use one of the php mysql_field_* functions.)



Paul Burney

    while ($self != "asleep") {

PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to