I have requirement where I need to populate the Column 'BK' with previous month with year.
Column - BK - Datatype - Number(6)- Format -YYYYMM
Current month, the job should run for previous month data based on the BK.
I tried the option MonthFromDate(CurrentDate())-1 ---> it is giving '8' for today. I want it as '08'
Like that I can take yearfromDate() and concatenate.
But the problem will be when next year 2018 comes, this above logic won't work.
Please let me know if there is any function to do this.
Thanks.
Calculate Previous Month with year
Moderators: chulett, rschirm, roy
Resolved the problem
Steps:
Stage variables
MonthFromDate(CurrentDate())-1=svPrevMonth-varchar
If Len(svPrevMonth)=1 then '0':svPrevMonth else svPrevMonth=svConMonth-varchar
YearFromDate(CurrentDate())=svYear-Varchar
YearFromDate(CurrentDate())-1=svYearCheck-varchar
If svConMonth=12 then svYearcheck:svConMonth else svYear:svConMonth=svConYearMonth-varchar
In Transformer
svConYearMonth......>BK
Steps:
Stage variables
MonthFromDate(CurrentDate())-1=svPrevMonth-varchar
If Len(svPrevMonth)=1 then '0':svPrevMonth else svPrevMonth=svConMonth-varchar
YearFromDate(CurrentDate())=svYear-Varchar
YearFromDate(CurrentDate())-1=svYearCheck-varchar
If svConMonth=12 then svYearcheck:svConMonth else svYear:svConMonth=svConYearMonth-varchar
In Transformer
svConYearMonth......>BK
Suja