Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
souvik
Contributor
Contributor

Dynamically convert a date into Year,Month

Hi All,

I need to segregate the month and Year from a Column names as  "Date" in which the dates are displayed like 1/12/2012,5/10/2014(MMDDYYYY) etc..

now created two more columns in the table just beside the Date: column, those are "Month" and "year"

Date                   Month      Year

1/12/2012             ---           ----

Now my question is how to put the 2012(YYYY) and 1(MM) i.e Janauary ,    value of the Date filed into my new "Year" and "Month" columns?

for example-----

Date                Year       Month

1/12/2012     2012      Jan

5/10/2014     2014      May

 

Can someone please help me solving this issue?

1 Solution

Accepted Solutions
nikitadeshwal
Partner - Contributor III
Partner - Contributor III

First, convert your Date to DDMMYYYY format using
date(date#(Date,'MM/DD/YYYY'),'DD/MM/YYYY')as Date;
then use functions
year(Date) as Year field
month(Date) as Month field

View solution in original post

2 Replies
tresesco
MVP
MVP

That should be pretty simple using qlik functions month() and year(), like:

Month(Date) as Month

Year(Date) as Year

However, if your Date field values are not read as proper dates by qlik, you might have use date parsing function date#() additionally like:

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

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

nikitadeshwal
Partner - Contributor III
Partner - Contributor III

First, convert your Date to DDMMYYYY format using
date(date#(Date,'MM/DD/YYYY'),'DD/MM/YYYY')as Date;
then use functions
year(Date) as Year field
month(Date) as Month field