Tested on -> TERADATA EXPRESS DATABASE 12.0 (Windows"XP 32 bit)
Somethign like this?
with tt(TMS_TMP,TMS_TMP1)
as
(
select '9999-12-31 23:59:59' tms_tmp,
'9999-12-31 11:59:59 AM' tms_tmp1
from scott.xdual
)
select tms_tmp TMS_TMP,
TMS_TMP(timestamp(6), format 'YYYY-MM-DDBHH:MI:SS') VENDOR_TMSTMP,
TMS_TMP1(timestamp(6), format 'YYYY-MM-DDBHH:MI:SSBT') VENDOR_TMSTMP1
from tt;By the way, don't panick on scott.xdual. :)
Thats a dummy view in order to replicate the dual features that is available in Oracle. You can follow TD methods instead of using it.
This is the way you can create this view in TD ->
create view scott.xdual
as
select 'X' dummy
from sys_calendar.caldates
where cdate='1900-01-01';So, you can see you need to have this select privileges on caldates object from sys_calendar DB.
Now, how to test whether it has successfully converted your string into timestamp or not?
Here is one way ->
create table scott.tmstmp_test
as
(
with tt(TMS_TMP,TMS_TMP1)
as
(
select '9999-12-31 23:59:59' tms_tmp,
'9999-12-31 11:59:59 AM' tms_tmp1
from scott.xdual
)
select tms_tmp TMS_TMP,
TMS_TMP(timestamp(6), format 'YYYY-MM-DDBHH:MI:SS') VENDOR_TMSTMP,
TMS_TMP1(timestamp(6), format 'YYYY-MM-DDBHH:MI:SSBT') VENDOR_TMSTMP1
from tt
) with data;We are creating a table based on our above query which actually converts the string data into timestamp. If our conversion is successful, the data type of the new set table TMSTMP_TEST should have timestamp data type.
Let's check the DDL of this newly created table ->
CREATE TABLE scott.tmstmp_test (
TMS_TMP VARCHAR(19),
VENDOR_TMSTMP TIMESTAMP(26),
VENDOR_TMSTMP1 TIMESTAMP(26)
);So, from the above test we can confirm that this is the way we have succesfully converted both 12 & 24 hours string into timetsamp value.
↧