All Forums Database
send2veda 1 post Joined 05/16
16 May 2016
Conversion of Integer to Date Format in Teradata

Hi, Good after nonn!
I have a table having a column Time_1 as integer data dtype and having values 201501, 201405 etc.. How do i convert it any to Date format like 'yyyy-mm-dd'
Basically i need to convert it to use Add_months on it so that i get last 3 months data.
 
Thanks in Advance..
 

sakthikrr 53 posts Joined 07/12
16 May 2016

Change it to the Teradata internal date format:

create table temp1
(
Time_1 integer
);

insert INTO temp1('201604');
insert INTO temp1('201605');
insert INTO temp1('201606');

select (time_1 - 190000) * 100 + 1 (date) from temp1;

 

Sakthi

yuvaevergreen 93 posts Joined 07/09
17 May 2016

SELECT ADD_MONTHS(TO_DATE('201501','YYYYMM'),-3)

You must sign in to leave a comment.