html output in plsql - date not proper
Question
I am trying to extract the below query:
select
'<tr><td>'||column1||'</td>',
'<td>'||column2||'</td>',
'<td>'||column3||'</td></tr>'
from table
In the above, column3 is a date field. When the output is printed, it is ignoring the time part. For example:
If columns 3 output is : 5/25/2011 3:03:17 AM
The above query returns : <tr><td>column1</td><td>column2</td><td>**25-JUN-11**</td></tr>
I have tried to_date(column3,'yyyy/mm/dd HH24:MI:SS') and also, the normal query prints the time
select
column1,
column2,
column3,
from table
columns 3 prints time. Any help is appreciated.
EDIT: I am using Oracle 10g. I have also tried it in Oracle 9i
La solution
Don't rely on implicit conversions, use TO_CHAR
to display a date to your liking:
select '<tr><td>'||column1||'</td>',
'<td>'||column2||'</td>',
'<td>'||to_char(column3, 'dd/mm/yyyy hh24:mi:ss')||'</td></tr>'
from table
Autres conseils
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow