Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Derive the Year

Hello

I have a period Name field that has values as Mar-14 where 14 stands for the the year.

If I want to derive the year from this field using the year function something like YearName([Period Name]=2014

What is the best way to achieve it?

3 Replies
robert_mika
Master III
Master III

Try

=YEAR(Date#('Mar-14 ','MMM-YY'))

or in script

=YEAR(Date#(Name,'MMM-YY')) as Year

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

If the period is a string you can do:

num(subfield(Period, '-', 2)) as Year

If the period was loaded as a Date, you can do:

Year(Period) as Year

-Rob

Not applicable
Author

Hi,

You can try this.

In Script.

Date(Date#(Year_Field_Name,'MMM-YY'),'YYYY')      as  Extract_Year,