Quantcast
Channel: Teradata Forums - Database
Viewing all articles
Browse latest Browse all 14773

Error while converting date to char - forum topic by bikky6

$
0
0

I have a table with date value stored in a char(10) format
CT KVB_DT(MYDATE CHAR(10))
INS INTO KVB_DT VALUES('20130620')
I need to add 7 days to it and it should be in char format as 20130627
I am able to add 7 days by converting it to date
SEL MYDATE,CAST(MYDATE AS DATE FORMAT 'YYYYMMDD') +INTERVAL '7' DAY  FROM KVB_DT
problem here is when I am trying to convert it it to char format.
SEL MYDATE,CAST(CAST(MYDATE AS DATE FORMAT 'YYYYMMDD') +INTERVAL '7' DAY AS CHAR(10) FORMAT 'YYYYMMDD') FROM KVB_DT
It is throwing error  YYYYMMDDdoesnt match the data type

Forums: 

Viewing all articles
Browse latest Browse all 14773

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>