sort by formatted date
Good morning to everybody.
I encounter a difficulty when formatting a date field by which I order the query with union.
If I make the query with the format that brings the date field (date_time) the result is correct
SELECT fecha, proveedor, importe from db.tb1
UNION
SELECT fecha, proveedor, importe from db2.tb1
order by fecha
but if I format the field with DATE_FORMAT() it orders it by days
SELECT DATE_FORMAT(fecha, "%d-%b") as fecha, proveedor, importe from db.tb1
UNION
SELECT DATE_FORMAT(fecha, "%d-%b") as fecha, proveedor, importe from db2.tb1
order by fecha
How can I correct the order when formatting the dates in different ways?
thank you very much once again for your help
Subject
Written By
Posted
sort by formatted date
February 11, 2022 02:16AM
February 11, 2022 09:45AM
February 11, 2022 10:19AM
February 11, 2022 10:21AM
February 11, 2022 10:59AM
February 11, 2022 02:20PM
February 15, 2022 10:06AM
February 17, 2022 12:05AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.