Page 1 of 1

Need to add 1 month to date

Posted: Thu May 12, 2011 3:46 am
by synsog
Hello everyone,

I am getting date in yyyy-mm-dd format,before loading to target I need to add 1 month to existing date.

For ex : 2011-05-31 need to load as 2011-06-30
2010-12-21 need to load as 2011-01-21.


Could any one suggest me the approach please........


Thanks in advance

Re: Need to add 1 month to date

Posted: Thu May 12, 2011 6:35 am
by Lohit Iti
Add this function in date column
ADD_MONTHS(TO_DATE(SYSDATE),1)

Re: Need to add 1 month to date

Posted: Thu May 19, 2011 7:44 am
by peddakkagari
I think the following Stage variables will help you

svNextMonth -
If ( Compare(MonthFromDate(Input_Date),'12') = 0 ) Then '01'
Else DecimalToString( (StringToDecimal(MonthFromDate(Input_Date)) + 1) ,'suppress_zero')

svNextMonthDate -
If ( Compare(MonthFromDate(Input_Date),'12') = 0 )
Then
DecimalToString( (StringToDecimal(YearFromDate(Input_Date)) + 1) ,'suppress_zero') :'-': ( If Len(svNextMonth) = 2
Then svNextMonth Else '0' : svNextMonth ) :MonthDayFromDate(Input_Date)
Else
YearFromDate(Input_Date):'-': ( If Len(svNextMonth) = 2 Then svNextMonth Else '0' : svNextMonth ) :MonthDayFromDate(Input_Date)

Posted: Thu May 19, 2011 4:54 pm
by ray.wurlod
What are the source and target? What are the source and target data types?