John John - 6 months ago 9
MySQL Question

Select date from sql and format this to text

I have a column in my database with type

date
. The name of these column is also
date
.

The format of the data in these column is:
2016-10-05
(yyyy-mm-dd). I want to SELECT the
date
for the first
id
as:
5 May 2016
.

I also want to select the date in another language.

How can I run this query?

Answer

The date is not stored as a string. It is stored as an internal representation. The YYYY-MM-DD format is simply how MySQL outputs the date.

If you want to format the date differently, convert it to a string using date_format() (see here). For your particular format:

select date_format(date, '%e %b %y')

(I should note that I personally much prefer the ANSI and ISO standard YYYY-MM-DD format.)

As for internationalization (support in other languages), you might want to start here in the documentation.