Is it possible to format a date field in a SELECT * query? I want to get all of the columns from my table but need a different format from the date.
Something like:
SELECT *, FORMATDATE(date,'%m-%d-%y') AS date FROM my_table;
or do I have to process it in php after the query?
Use DATE_FORMAT:
SELECT *, DATE_FORMAT(date, "%m-%d-%y") AS date FROM my_table;
select DATE_FORMAT(your_date_field_name,'%m-%d-%y') AS whatever FROM your_table_name_here;
the result is something like this
09-22-11
as opposed to this
2011-02-02 15:42:51
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With