How to put a day, month and year placeholder in Mysql?

Asked

Viewed 87 times

0

I need to add a date column of the invoice, organized by month day and year (dd/mm/yy). How do I leave this preset time format in Mysql Workbench?

  • You want to leave the format dd/mm/aa instead of the default Mysql date type at the time of select?

  • That’s right, that’s right

1 answer

1


If you store your dates with datetime or date there is no way, has to treat in select. It’s quite simple:

SELECT data, DATE_FORMAT(data,'%d/%m/%Y') as data_formatada
FROM tabela
ORDER BY data ASC

This script should select the date the way it is ( data), date in dd/mm/YYYY format (data_formatada) and orders from the oldest to the newest. To reverse the ordering, change ASC for DESC.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.