Cyber Junkie
Cyber Junkie

Reputation: 766

DATE_FORMAT() in MySQL query

I'm trying to change this timestamp

2010-08-02 00:28:20

to month/day/year -

08/02/10

..in the query (I know that doing it in the query is faster).

$sql = "SELECT * FROM posts ORDER BY post_date DESC";

I tried using the DATE_FORMAT() in the query many ways but I can't seem to get it right.. Can someone please share how to do this?

Upvotes: 4

Views: 13690

Answers (1)

Pekka
Pekka

Reputation: 449395

Using the manual on DATE_FORMAT():

SELECT DATE_FORMAT(post_date, "%m/%d/%y");

Upvotes: 7

Related Questions