How to select a date in the dd/mm/yyyy format in mysql?

Asked

Viewed 5,358 times

1

Good morning/late/evening

I need to select a field TYPE DATE in mysql, the data is in the format yyyy-mm-dd, I need you to come back dd/mm/yyyy. Is there any way to do this in select?

I’ve seen solutions with the function date_format, but I was unsuccessful.

Thanks in advance.

  • If you could put your SQL ???

  • 2

    What exactly didn’t work? How did you execute, can you ask the question? It works like this: SELECT DATE_FORMAT(NomeDoCampoDate,'%d/%m/%Y') AS DataFormatada

  • So your field in the table is not date? it is a varchar?

  • Thanks guys, solved. I posted the answer. I was doing it the wrong way even.

  • 1

    Normally I usually convert the parameter date to the database default and not the other way around

  • Wrong @diegofm, here the field is date type and not varchar.

Show 1 more comment

1 answer

2


I was doing it the wrong way. I ended up trying it again and it worked.

SELECT DATE_FORMAT(STR_TO_DATE('campo', '%Y-%m-%d'), '%d/%m/%Y') FROM 'tabela'

Browser other questions tagged

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