Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
shree909
Partner - Specialist II
Partner - Specialist II

converting month_name to month_number

hi

i have a month name  and i want to convert it into month_number.

i am getting only month_name form the datasource,

ex: if it is june , i want to convert to  06

5 Replies
Gysbert_Wassenaar

Use a mapping  and applymap to add the month number

MonthMap:

Mapping LOAD * INLINE

[    month_str, month_num    

     Januari, 01    

     Februari, 02    

     March, 03    

     April, 04    

     May, 05    

     June, 06    

     July, 07    

     August, 08    

     September, 09    

     October, 10    

     November, 11    

     December, 12

];

SomeTable:

load

a,

b,

c,

MyMonth,

ApplyMap('MonthMap',MyMonth)

from ...etc


talk is cheap, supply exceeds demand
shree909
Partner - Specialist II
Partner - Specialist II
Author

other than apply map is there any solution like writing functions to convert ...

MayilVahanan

Hi

Try like this

Num(Month(DateField)) as Month for 6

Hope it helps

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
shree909
Partner - Specialist II
Partner - Specialist II
Author

thanks for the reply but i have only month_name but not datefeild ..then how?

MayilVahanan

Hi

Then you can try gwassenaar method or just inline table

LOAD * INLINE

[    Month, MonthNum   

     January, 01   

     February, 02   

     March, 03   

     April, 04   

     May, 05   

     June, 06   

     July, 07   

     August, 08   

     September, 09   

     October, 10   

     November, 11   

     December, 12

];

Load MonthField as Month, * from tableName;

And use 'MonthNum' whenever you need..

Hope that helps

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.