The date attribute doesn't show the full value. is there a way to stretch the attribute size?
CodePudding user response:
A DATE
is a binary data-type that consists of 7-bytes representing: century, year-of-century, month, day, hour, minute and second. It ALWAYS has those components.
The issue you are seeing is that the client application you are using (which appears to be SQL*Plus) is choosing not to display the full components of the date and you need to fix how the client application displays the DATE
value and (probably) not how you retrieve the value from the database.
SQL*Plus uses the NLS_DATE_FORMAT
session parameter as the format model for displaying DATE
s.
You can either set the NLS_DATE_FORMAT
session parameter using:
ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-MM-DD HH24:MI:SS';
Note: You would need to make sure that format model is applied in every session where you want that format.
Or you can return a non-DATE
data type such as a string formatted with your desired format model:
SELECT student_id,
first_name,
last_name,
TO_CHAR(date_of_birth, 'YYYY-MM-DD HH24:MI:SS') AS date_of_birth,
major,
phone,
cogname
FROM table_name;
CodePudding user response:
Just suggest execute below SQL in advance in the same connection session:
alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss'