Timestamp field into oracle by using sqlloader - oracle

I am trying to load this source row into oracle
Source row:
1000-01-01 00:00:00:000000
by using this CTL statement;
entrydate TIMESTAMP "YYYY-MM-DD hh:mi:ss:ff6"
but I am getting
ORA-26041: DATETIME/INTERVAL datatype conversion error
What am I doing wrong?

Timestamp format or data problem hh - Hour of day (1-12). hh24 - Hour of day (0-23).
TIMESTAMP "YYYY-MM-DD hh24:mi:ss:ff6" try this version.

Related

Fetch Hours from Created date

I'm just trying to fetch Hour of my table from created date in Oracle 12c Database but it is showing error INVALID EXTRACT FIELD FOR EXTRACT FIELD. kindly guide me to fetch hour of my date my code is here...
SELECT
EXTRACT( HOUR FROM (TO_CHAR(CREATED_DATE,'RRRR-MM-DD HH:MI:SS')) ) HOUR
FROM
INVOICE_V;
my Date is stored as 6/1/2020 4:04:50 PM in this format and Extract function is not accept this function.
Do not store dates as strings.
But, since you have, convert it from a string to a date using TO_DATE:
SELECT EXTRACT( HOUR FROM TO_TIMESTAMP(CREATED_DATE,'DD/MM/YYYY HH12:MI:SS AM') ) AS HOUR
FROM INVOICE_V;
If, however, you meant that its just displaying in that format (and is actually a DATE data type) then CAST the date to a timestamp:
SELECT EXTRACT( HOUR FROM CAST( CREATED_DATE AS TIMESTAMP) ) AS HOUR
FROM INVOICE_V;
An hour can not be used in the EXTRACT function.
The only way to extract hour is to use TO_CHAR or subtract it from TRUNC date as follows:
TO_CHAR(created_date,'HH24') -- OR 'HH' as per your requirement
-- OR
FLOOR(24*(created_date- TRUNC(created_date)))
Please note that Oracle does not store dates in any format. It has its own binary representation. What you see while selecting from the table is based on the NLS_DATE_FORMAT parameter.
You can set it according to your requirement.
ALTER SESSION SET NLS_dATE_FORMAT = 'YYYY-MM-DD HH24:MI:SS'; -- like this
If you have a date column (or the-like), then:
select extract(hour from cast(created_date as timestamp)) as hr
from invoice_v
Alternatively:
select to_char(created_date, 'hh24') as hr
from invoice_v
The first expression returns an integer number, while the second produces a string.
Note that hour is a language keyword, hence not a good choice for an identifier (here, you used it as a column alias). I changed that.

create oracle date with time stamp from HH24 string

I have hour in 'HH24' format. For example: '13:35' I need to convert this into today's date of '13:35' in the time stamp - "dd/mm/yyyy HH24:MI:SS".
To_timeStamp() method returning me the date with timestamp of starting of the month.
It is returning "01-Jul-2019 13:35:00", please help me to get today's date with the exact hour and minutes?
You need to concatenate the formatted date with your input and then convert that back to a timestamp:
select to_timestamp(to_char(sysdate, 'yyyy-mm-dd')||' 13:35', 'yyyy-mm-dd hh24:mi')
from dual;
If that time value is a column in your table, use that instead of the constant value:
select to_timestamp(to_char(sysdate, 'yyyy-mm-dd')||' '||the_time_column, 'yyyy-mm-dd hh24:mi')
from your_table;

Issue converting timestamp(6) '31-DEC-99 12.00.00.000000000 AM' to character

I am exporting some data from a table in an Oracle database to csv files. All the date and time columns are timestamp(6). In the select statement I convert them with
to_char(TERMINAL_ARRIVAL_TIME, 'YYYY-MM-DD HH24:MI:SS.FF') as TERMINAL_ARRIVAL_TIME
This works fine for all dates except for the default values 31-DEC-99 12.00.00.000000000 AM. These values result in an invalid date of 1900-01-00 00:00:00.000000.
Have I understood this correctly ? What is the correct way to convert this timestamp to character ?
What I expected was 9999-12-31 00:00:00.000000.
What it produced was 1900-01-00 00:00:00.000000

How to fetch the date from epoch in CockroachDB

I have a column which has the time stamp stored in epoch. I need to fetch the date from the epoch time stamp. For instance for epoch = 1552942715, I need to fetch the date as 1552867200. How can this be achieved?
create table test (epoch text NULL);
Create table sample where the column is text datatype.
select (epoch::int)::TIMESTAMPTZ from test;
If the column is of type int or any other number then just cast it to timestampz

Timestamp to complete date format

We are working on oracle 11g enterprises edition. We are facing issue in getting value of date for type TIMESTAMPTZ and TIMESTAMPLTZ. We are storing those dates into one csv file using apache metamodel. We are fetching date from database using :
TIMESTAMPLTZ columnValue = (TIMESTAMPLTZ) row.getValues()[pos];
Timestamp timestamp=columnValue.timestampValue(connection,Calendar.getInstance(Locale.getDefault()));
Date dateByTimeStamp=new Date(timestamp.getTime());
Date dateByDateValue = columnValue.dateValue(connection);
String formattedDate = new SimpleDateFormat("dd-MMM-yy hh.mm.ss.SSSSSS a").format(dateByTimeStamp or dateByDateValue );
dateByDateValue contains date upto yyyy-mm-dd hh:mm:ss format. eg. 2016-10-12 08:49:30. There is no way to get value of nanoseconds and time zone using this object.
dateByTimeStamp object contains cdate that have value of date upto nanoseconds and also have time zone. But the value of date time differ because of time zone, but this cdate object contains information regarding nanoseconds precision.
Is there any way to get date in complete format so that the formatted date can directly be used to restore into another oracle db?

Resources