Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Manipulation of date fields

Hello all!

I have a question concerning on how to manipulate date fields. Currently I have YearMonth in the format YYYY/MM ranging from 2012/10 to 2013/09:

year months.png

Due to demonstration purposes I want to transform the YearMonth field in a way that I can analyse my data only for year 2012. So, how can we change for example 2012/10 to 2013/10 and 2012/11 to 2013/11?

Thank you very much in advance!

Best regards,

Heiko

4 Replies
Not applicable
Author

Hi Heinko,

I have no idea why you would want to do this but you can do it this way.

left(YearMonth,4) +1 & mid(YearMonth,6,2) as Field.


Regards,
Marius

Not applicable
Author

Sorry, you would have to include '/' as well.

So do left(YearMonth,4) +1 & '/' & mid(YearMonth,6,2) as Field.

Regards,
Marius

Not applicable
Author

Hello Marius,

thanks a lot for your response. Could you please explain me shortly whats the mid function doing?

thx and regards,

Heiko

Not applicable
Author

Hi Heinko,

When you use the mid function you specify which position in a string you want to pull values out of and how many caracters.

Meaning mid(YearMonth,6 (Start at Caracter 6),2 (Fetch 2 caracters from position 6).

QlikView's example:

Substring of the string s. The result is the string starting at character n1 with the length of n2 characters. If n2 is omitted, the function returns the rightmost part of the string starting at character n1. The positions in the string are numbered from 1 and up.

mid('abcdef',3 ) returns 'cdef'.

mid('abcdef',3, 2 ) returns 'cd'.

mid( Date,3 ) where Date = 970714 returns 0714.

mid( Date,3,2 ) where Date = 970714 returns 07.

Regards,
Marius