I have to put in STIMING
a time when I insert I use TO_DATE
function but it give me date not time and it should be time.
This is the table
I suggest you to avoid updates, change your insert part from to_date
with no formatting param to to_date( colname, 'DD-MON-YY HH24:MI:SS')
I have to put in
STIMING
a time
Oracle does not have a TIME
datatype. The DATE
data type is always stored internally as 7-bytes and is always composed of year (2-bytes) and month, day, hours, minutes and seconds (1-byte each).
You cannot not have a year, month or day component of a DATE
.
If you want a time on its own then you will have to store it as a different data type or store the year/month/day and ignore that component.
When you are SELECT
ing the STIMING
column it is not showing the time component. You can change this by changing the default date format which is set in the NLS_DATE_FORMAT
session parameter.
You can review this parameter using:
SELECT VALUE FROM NLS_SESSION_PARAMETERS WHERE PARAMETER = 'NLS_DATE_FORMAT';
You can set this value within your current session using:
ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-MM-DD HH24:MI:SS';
(Note: this does not change the value for any other users.)
When you insert the date you can use:
INSERT INTO shift ( SNO, SNAME, STIMING)
VALUES ( 121323, 'morning', TO_DATE( '01-APR-2017 07:00' DD-MON-YYYY HH24:MI' ) )
Or, an ANSI TIMESTAMP
literal (which will be implicitly cast to the DATE
format of the column):
INSERT INTO shift ( SNO, SNAME, STIMING)
VALUES ( 121323, 'morning', TIMESTAMP '2017-04-01 07:00:00' )