Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
arulsettu
Master III
Master III

get month and year from month/year

hi

i am having data like this

Year

03/2016   

03/2015   

01/2016   

12/2015   

01/2015   

05/2015   

06/2015   

02/2016   

11/2015   

08/2015   

10/2015   

04/2016   

05/2016   

09/2015   

07/2015   

04/2015   

02/2015              

];

i did the following

LOAD*,

month(SubField(Year,'/','1')) as newmonth,

Year(SubField(Year,'/','1')) as newyear;

but not getting the result

any idea?

1 Solution

Accepted Solutions
tresesco
MVP
MVP

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

Year(Date#(Year, 'MM/YYYY')) as Year

View solution in original post

10 Replies
tamilarasu
Champion
Champion

Try.

LOAD*,

Month(Date#(SubField(Year,'/','1'),'MM')) as newmonth,

SubField(Year,'/','2')) as newyear;

pooja_sn
Creator
Creator

Left(Year,2) will give month and

Right(Year,4) will give year

Mark_Little
Luminary
Luminary

HI,

I would say it because you are just present the number and asking from the month or Year.

Normally you would use them to strip out a month or year from a date. so maybe try

Month(DATE(Year,MM/YYYY)) AS Newmonth,

Taking out the Month() and Year() functions should work to.

Also

Left(Year,2) as Newmonth,

Right(Year,4) as Newyear

Mark

arulsettu
Master III
Master III
Author

month is fine

year i am having 2015,2016

but result is

2001 to 2012

why?

vikasmahajan

PFA

Vikas

Hope this resolve your issue.
If the issue is solved please mark the answer with Accept as Solution & like it.
If you want to go quickly, go alone. If you want to go far, go together.
tresesco
MVP
MVP

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

Year(Date#(Year, 'MM/YYYY')) as Year

tamilarasu
Champion
Champion

I have changed it.

SubField(Year,'/','2')) as newyear;

arulsettu
Master III
Master III
Author

i will try and get back

thanks

MK_QSL
MVP
MVP

Data:

Load

  MonthYearField,

  Month(Date#(MonthYearField,'MM/YYYY')) as Month,

  Year(Date#(MonthYearField,'MM/YYYY')) as Year

From YourTableName;