DATE_FORMAT - Mysql function

Asked

Viewed 218 times

0

I have this query below, which brings all the information I need. However the field Resolution is with the date (yy-mm-dd), I need it to return with the date formed as dd/mm/yy:

select * 
FROM denuncia 
WHERE resolution BETWEEN ('2018-01-01') AND ('2018-12-31') 
ORDER BY resolution ASC;

With this query, bring the formatted date:

select resolution, DATE_FORMAT( `resolution` , '%d/%c/%Y' ) AS `resolution` 
FROM denuncia;

I cannot join these two queryes to make the first select and bring the dates formatted according to the second.

  • Use another alias for the formatted date, example AS resolution_label

1 answer

0


You can specify the fields you want to bring from the table:

select id, DATE_FORMAT( `resolution` , '%d/%c/%Y' ) AS `resolution`/*, demais_campos*/
FROM denuncia 
WHERE resolution BETWEEN ('2018-01-01') AND ('2018-12-31') 
ORDER BY resolution ASC;
  • 1

    Good, it worked. Thank you.

Browser other questions tagged

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