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

Announcements
Posting on Qlik Community is temporarily paused for some users. Thank you for patience and we'll update you soon!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Creating Month-Year Field From Date

Hi all,

I'm currently trying to convert a date value (eg 01/01/2013, DD/MM/YYYY) to a month-year format - Jan-13. In my script I am using the following line to achieve this:

Date(date,'MMM-YY') AS MonthYear

What I expect to see is a single row for each unique MonthYear value. What I get though is what appears to be a new row for each day of the month for a given MonthYear value:

monthYear.PNG

It's as if the field is displaying the date correctly but somewhere in the back end there is extra date data attached to the row. I have other apps that use similar code but don't exhibit this behavior. Any ideas what's going on?

Thanks,

Adam

Labels (1)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Hi Robert,

Thanks for the suggestion. After a little more research I've found that the following code does what I like without needing to convert the date to text:

date(monthstart(date,), 'MMM-YY'))

Thanks again,

Adam

View solution in original post

2 Replies
robert_mika
MVP
MVP

try this:

t1:

load * Inline

[

datek

01/01/2013

02/01/2013

02/02/2013

01/01/2013

01/03/2013

02/03/2013

]

;

t2:

DATE(makedate(right(datek,4),mid(datek,4,2)),'MMM-YY') as MonthYear

Resident t1;

DROP TABLE t1

Anonymous
Not applicable
Author

Hi Robert,

Thanks for the suggestion. After a little more research I've found that the following code does what I like without needing to convert the date to text:

date(monthstart(date,), 'MMM-YY'))

Thanks again,

Adam