while importing .txt file in teradata iam getting invalid time stamp.Actually file contains time stamp data like 20180607123456000 - teradata

I have a .txt file contains time stamp column like 20180607093059000 and some other columns, but while importing into teradata SQL assistant getting invalid time stamp error. please help me the way
as I need to import file data into volatile and has to do minus operation between these file table and actual table.

The default format for a timestamp is 'YYYY-MM-DD HH:MI:SS', you can apply TO_TIMESTAMP
To_Timestamp(ts, 'yyyymmddhhmissff3')
which results in a Timestamp(6)
To get Timestamp(3) you need to CAST using a FORMAT after adding the fractional period:
Cast(Substring(ts From 1 FOR 14) || '.' || Substring(ts From 15) AS TIMESTAMP(3) FORMAT 'yyyymmddhhmiss.s(3)')

Related

convert the time columns to DolphinDB TIME when importing live market data

When importing a CSV file containing live market data to DolphinDB, how to convert the time columns to the DolphinDB TIME type time in DolphinDB? For example, the csv file contains a time value 093000000 which will be parsed as a string if I import the file with loadText. How can I convert it to 09:30:00.000, the TIME data type?
If you have imported the data into DolphinDB, use temporalParse to convert strings to temporal types in DolphinDB.
temporalParse( "093000000", "HHmmssSSS")
If you haven't yet imported the CSV file, use loadText. Use the schema parameter to specify the time format of the temporal column.
Check the code sample below:
schema = extractTextSchema("yourFilePath");
update schema set type="TIME" where name = "yourTimeColumnName" //modify the data type of a specified column
update schema set format="" // Add a format column to the variable schema
update schema set format="HHmmssSSS" where name = "yourTimeColumnName" // Modify the time format of the specified TIME column
loadText("yourFilePath",,schema)

How to convert VARCHAR DATE to Date Format in teradata 15?

I loaded data from csv file with fastload in Tera Data Express 15. In csv file my ModifiedDate format is 6/12/2004 0:00 and in fastload script my Date type is varchar
I create a new table now I want to load data from one table to another table
How to convert varchar date to date format?
You can use a regular expression to add missing leading zeroes before casting to a timestamp:
Cast(RegExp_Replace(start_date, '\b([0-9])\b', '0\1') AS TIMESTAMP(0) Format 'dd/mm/yyyyBhh:mi')
Of course an easier way would be using TPT (instead of legacy FastLoad) which supports such formats out of the box (VarDate).

Teradata Fastload date format issue

I have a flat file which I am trying to load through fastload. The flat file has date in the format dd/mm/yyyy. When I am trying to load it through fastload the records are going in the Error tables. However, when I change the format of date in the flat file as yyyy-mm-dd 00:00:00 its loading for that column its loading fine.
07/27/2011 00:00:00 -- not working
2011-12-15 00:00:00--working
errlimit 1000000;
tenacity 4;
sessions 1;
sleep 6;
dateform Ansidate,
SET RECORD VARTEXT "|*|" ;
I am taking dateform Ansidate in the script
ANSIDATE always expects yyyy-mm-dd format.
You need to add a Teradata style typecast in your INSERT using a FORMAT matching your input string:
:PROMISE_DTTM(timestamp(0), format 'mm/dd/yyyyBhh:mi:ss')

Fastload to temporal table

Had a cvs file containing 3 fields
1,cat,2012-06-16,2013-06-16
1,cat,2013-06-16,
I am trying to load that to temporal table having valid_dt PERIOD(DATE) using fastload script
nonsequenced validtime
INSERT INTO financial.test1 (id,name,valid_dt) values
(:id,:name,period( cast(:start_dt as date FORMAT 'YYYY-MM-DD'),cast(:end_dt as date FORMAT 'YYYY-MM-DD'))
);
Error I got is RDBMS error 3618: Expression not allowed in Fast Load
Insert, column INTERNALPERIODDATETYPE.
could not find any in manuals, they only said it will be possible with fastload.
Thankyou.
FastLoad doesn't allow ANSI style CAST, must be old Teradata style instead:
:start_dt (date, FORMAT 'YYYY-MM-DD')
But there's no old-style PERIOD cast and FastLoad also doesn't allow any kind of expression and PERIOD(...) is an expression.
So you can only load data which can be automatically converted to a PEROD like:
1;cat;(2012-06-16, 2013-06-16)
1;cat;(2013-06-16, 9999-12-31)
Including the parens, the blank after the comma and a different delimiter...
I would suggest simply loading the data as DATEs (or CHARs) into a staging table using FastLoad or MultiLoad, followed by a
nonsequenced validtime
INSERT INTO financial.test1 (id,name,valid_dt) values
select id, name, period(start_dt,COALESCE(end_dt, date '9999-12-31'))
from stagingtable

SQL Developer: Load Data Date error

I am using Oracle SQL Developer 3.0.03. I am trying to upload an Excel file to an Oracle data table. I am getting an error for the date. The column in the database is a timestamp and I don't know what to put into the date format for the 'Data Load Wizard'. If I use the following format (dd-mom-yy hh.mi.ss), SQL Developer will show the following error:
--Insert failed for row 1 TIMESTAMP_COLUMN GDK-05047: A day of the month must be between 1 and the last day of the month.
--Row 1
INSERT INTO TABLE_1 (Column1, Column2, Column3, TIMESTAMP_COLUMN) VALUES ('Some Text','Some Text','Some more text',to_timestamp('40604.0', 'dd-mon-yy hh.mi.ss'));
The default number format IN EXCEL is: 40604.0
Which if you change the cell to a short date format you will get: 3/2/2011
I am trying to figure out what 'Format' I need to put into the FORMAT section of the 'DATA Load Wizard' that will accept the date format that is in EXCEL and upload it to Oracle as a TIMESTAMP.
I ran into the same thing today, and 'fixed' this two ways. The second way probably seems too complex, but it might help someone if they have a hard time automating the formatting of dates to look like Oracle's standard dd-mmm-yy.
Format the date columns in Excel as dd-mmm-yy and import directly into the table.
Highlight the column(s)
Choose "More Number Formats" where the existing format is (In Excel 2010, it says General in a dropbox on the Home tab
Select the last entry "Custom" in the Category box
Manually enter dd-mmm-yy in the Type: box
Format the date columns in Excel as mm/dd/yy, import the table in as text, write a manual insert statement from the temp text table using TO_DATE(date_field,'MM/DD/YYYY')
Highlight the column(s)
Choose "More Number Formats" where the existing format is (In Excel 2010, it says General in a dropbox on the Home tab
Select the "Date" entry in the Category box
Choose "03/14/01" from the list
The Excel "zero" date is January 0 (yes, zero), 1900. Since Oracle can't handle a "zero" day in a month you need to subtract 1 from the Excel value; thus the following should get you close to what you want:
SELECT CAST(TO_DATE('01-JAN-1900 00:00:00', 'DD-MON-YYYY HH24:MI:SS') AS TIMESTAMP) +
NUMTODSINTERVAL(41017.6361109954 - 1, 'DAY')
FROM DUAL
As far as "how to import it" goes, there's no Oracle date format that I'm aware of to do this. The easiest thing would be to import the value into a NUMBER column and then run a script to do the date conversion.
Share and enjoy.
yeah and that's the problem.
"A day of the month must be between 1 and the last day of the month."
1) how are these decimals created?
2) is this "04-06-2004" ? or are these seconds from 1970?
you need to add more detail about this number format!

Resources