Conversion of Integer to Date Format in Teradata

Database

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..

2 REPLIES
Enthusiast

Re: Conversion of Integer to Date Format in Teradata

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;
Enthusiast

Re: Conversion of Integer to Date Format in Teradata

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