Pregunta

I have date displayed like that :

date

So here is how it works, an user fills a form, when he cliks on submit button, I save the datas in my db with a procedure, and I add sysdate in order to make an id for each form submitted. So I make an INSERT TO, with DATE_ID = sysdate. Then I show all the form submitted on an admin page. I want to display time with date provided by sysdate so I make the TO_CHAR. One group of item = One submit.

Here is how I show sysdate :

select to_char(DATE_ID, 'DD/MM/YYYY HH24:MI:SS') as DATE_ID

and order it with

ORDER BY DATE_ID DESC;

How can I order date with the time?

¿Fue útil?

Solución

I think what you mean is to sort by the stored date/time values not as the converted character values, so just prefix the column with the table alias in the ORDER BY:

SELECT to_char(DATE_ID, 'DD/MM/YYYY HH24:MI:SS') as DATE_ID
FROM some_table tbl
ORDER BY tbl.DATE_ID DESC;

Otros consejos

Use an alias name that does not equal the actual column name. Then your code should work.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top