Kevin
Kevin

Reputation: 13226

Convert timestamp to a readable date during query

How can I tell MySQL to format a timestamp as a readable date before outputting a query result in a MySQL client/console?

Upvotes: 5

Views: 18251

Answers (2)

mlusiak
mlusiak

Reputation: 1054

SELECT DATE_FORMAT(column_name, '%d/%m/%Y') FROM tablename

Reference

You can also use TIME_FORMAT

Upvotes: 5

Emil Vikström
Emil Vikström

Reputation: 91983

Use FROM_UNIXTIME like this:

SELECT
  FROM_UNIXTIME(timestamp_field) AS formatted_date
FROM
  tablename;

Upvotes: 11

Related Questions