Solved

oracle, 10, database, using carriage return

Posted on 2008-06-17
7
681 Views
Last Modified: 2013-12-18
folks,how can i use oracle to define a carriage return of a date field

my field is reportdate  13-06-2008 14:25:02 and i want the field to display

reportdate
13-06-2008
14:25:02

im hesitant of it working but all help will do

r
0
Comment
Question by:rutgermons
7 Comments
 
LVL 16

Expert Comment

by:Milleniumaire
ID: 21801457
It depends which tool you are using to display the output.

The following characters will display a newline on a unix system:

chr(13)||chr(10)

For example:

declare
  newline varchar2(2) := chr(13)||chr(10);
begin
  dbms_output.put_line('Line1'||newline||'Line2');
end;
/
0
 
LVL 47

Expert Comment

by:schwertner
ID: 21801775
CHR(10) is enough!
0
 

Author Comment

by:rutgermons
ID: 21801942
example?
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 16

Expert Comment

by:Milleniumaire
ID: 21801970
Dug the example out of some code.  Not sure why they use chr 13 and 10, but chr 10 is enough to give a newline as follows:
declare
  newline varchar2(1) := chr(10);
begin
  dbms_output.put_line('Line1'||newline||'Line2');
end;
/
0
 

Author Comment

by:rutgermons
ID: 21802111
how do i dump this into a select type query according to my intial question?
0
 
LVL 34

Accepted Solution

by:
johnsone earned 500 total points
ID: 21802438
select to_char(sysdate, 'dd-mm-yyyy') || chr(10) || to_date(sysdate, 'hh24:mi:ss');
0
 
LVL 16

Expert Comment

by:Milleniumaire
ID: 21802593
Or, to ensure you get the required heading:

select to_char(reportdate, 'dd-mm-yyyy') || chr(10) || to_date(reportdate, 'hh24:mi:ss') reportdate
from yourtable;
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Oracle RAC 12c 8 72
Wrap Oraccle SQL*Plus executable Command 4 84
Queries 15 38
Component is listed with a Protocol more than once 3 29
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question