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).
Related
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)')
I have a value '2017-09-27T19:25:15.927-07:00', is there any way to convert this into a timestamp?
I use Hive 1.1.0.
select unix_timestamp("2017-09-27T19:25:15.927-07:00", "yyyy-MM-ddTHH:mm:ss.SSSX") but it trows Bad date/time conversion format
select unix_timestamp("2017-09-27T19:25:15.927-07:00", "yyyy-MM-ddTHH:mm:ss.SSSZZZ") but it returns NULL
The format is yyyy-MM-dd'T'HH:mm:ss.SSSXXX".Note the single quotes surrounding 'T'
select from_unixtime(unix_timestamp("2017-09-27T19:25:15.927-07:00", "yyyy-MM-dd'T'HH:mm:ss.SSSXXX"))
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')
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
Good Morning,
A program in SAS is about to select/merge/sort dates/times in alphanumeric value (ex : 14-Jan-2013 07:00:00.479) inside a lot of tables and to create a single table.
This program use the instruction "format E8601" and several lines after "format type $10.;
informat type $10.;", what transforms the dates in a numeric value (ex : 2013-01-14T07:02:03.647).
When this table is exported in Excel 2007, the value becomes " " and can't be modified in a traditional date/time format.
How to do it ? Is there any other format (instead of E8601) which can be used to keep the date in text or in a alphanumeric value ?
Thanks for your help.
SAS datetime values are internally represented as floating point values equal to the number of seconds since January 1, 1960. FORMATS are used to control how those numeric values are externally represented. For example, consider this:
data have;
myDateTime1 = '14-Jan-2013 07:00:00.479'dt;
myDateTime2 = '14-Jan-2013 07:00:00.479'dt;
myDateTime3 = '14-Jan-2013 07:00:00.479'dt;
format myDateTime2 datetime23.3
myDateTime3 E8601DT23.3;
put myDateTime1= 'as a number'
/ myDateTime2= 'as a normal SAS datetime'
/ myDateTime3= 'as an ISO 8601 datetime'
;
run;
When run, this is shown in the SAS log:
myDateTime1=1673766000.5 as a number
myDateTime2=14JAN2013:07:00:00.479 as a normal SAS datetime
myDateTime3=2013-01-14T07:00:00.479 as an ISO 8601 datetime
Note the three myDateTime variables have the same value but are displayed differently based on the format specified.
Assuming you have SAS Access to PC File Formats licensed, you can just use PROC EXPORT to create an Excel workbook:
proc export data=have
outfile='c:\temp\test_dates.xlsx'
replace;
run;
The data values in the Excel workbook for the two variables formatted as "datetime" values will appear correctly as Excel columns. However, the default formatting in Excel only shows the "date" portion; to display the complete value in Excel you will need to change the Excel column formats.