RE: [PHP-DB] mysql time format
| From: | John W. Holmes | Date: | Tue, 07 Jan 2003 02:40:02 +0000 |
| Subject: | RE: [PHP-DB] mysql time format | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-24609@lists.php.net to get a copy of this message | ||
> This is a bit of a newbie question, but I couldn't find what I wanted
in
> the documentation.
>
> 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.
What type of column are you using? TIME()? If so, then there's no way to
do this without using TIME_FORMAT() in each of your queries. If you're
using a TIMESTAMP column, you can specify the length to XX so that it
only stores data in a YYYYMMDDHHMM format.
---John W. Holmes...
PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/