mysql DATE_FORMAT() question
| From: | Adam Williams | Date: | Wed, 12 Dec 2007 16:44:22 +0000 |
| Subject: | mysql DATE_FORMAT() question | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-265776@lists.php.net to get a copy of this message | ||
I ran the commands:
CREATE TABLE testtable ( testdate DATETIME);
INSERT INTO testtable (testdate) VALUES (now());
and then I want to select it but format it to show the date only (not the time, and yes I know I could use DATE instead of DATETIME, but there may be cases where I need to show the time also). So I run:
select DATE_FORMAT(testdate, '%m\-%d\-%Y') from testtable AS date_column;
+-------------------------------------+
| DATE_FORMAT(testdate, '%m\-%d\-%Y') |
+-------------------------------------+
| 12-12-2007 |+-------------------------------------+ now my question is, why is the column heading DATE_FORMAT(testdate, '%m\-%d\-%Y') even though I told it to be called date_column?