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: 
cliff_clayman
Creator II
Creator II

How can I separate a Year/Month field into two fields in script

I have a field named [Year/month] and the values look like this: 2018/01  I need to pull out the Year value and the Month value as a name.  I want to do this in the script.  How can I do this?

10 Replies
MK_QSL
MVP
MVP

Date#([Year/month],'YYYY/MM') as [Year/month],

Year(Date#([Year/month],'YYYY/MM')) as Year,

Month(Date#([Year/month],'YYYY/MM')) as Month

ychaitanya
Creator III
Creator III

use the subfield function in the expr where ever you would like to

subfield([Year/month],'/',1) for field Year and subfield([Year/month],'/',2)  for Month

wdchristensen
Specialist
Specialist

Left([Year/month], 4) AS MyYear, Right([Year/month], 2) AS MyMonth

cliff_clayman
Creator II
Creator II
Author

I need the MyMonth to be Month name and not Month num.

ychaitanya
Creator III
Creator III

use inline load  as

Mnth_Map:

Mapping Load * INLINE

[ Mnth_Num,Mnth_Name

1, Jan

2,Feb

3,Mar

]

then use

ApplyMap('Mnth_Map',subfield([Year/month],'/',2) ) as Month_Name,

subfield([Year/month],'/',1)  as Year

MK_QSL
MVP
MVP

Have you tried as per my answer?

You will get something like below.

Capture.JPG

wdchristensen
Specialist
Specialist

Month(MakeDate(2018,Right([Year/month], 2))) as MyMonthName

cliff_clayman
Creator II
Creator II
Author

I need the full moth name.

MK_QSL
MVP
MVP

Data:

Load

Date#([Year/month],'YYYY/MM') as [Year/month],

Year(Date#([Year/month],'YYYY/MM')) as Year,

Date(Date#(Month(Date#([Year/month],'YYYY/MM')),'MMM'),'MMMM') as Month

Inline

[

Year/month

2018/01

2018/02

2018/03

];