Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Can I create distinct Month & Year from loaded data ?


I have already loaded 2 million records. Is there a way to create year & month from my doc_date ?  I have used month(doc_date) which returns the month but in many lines.

11 Replies
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi Michael,

I would disagree that either Month() or MonthStart() could be used here. It depends on how you want to group things. Month() returns only the month, not the year. MonthStart includes the year, and therefore is different.

Month('01/01/2013') = Month('01/01/2012')

MonthStart('01/01/2013') <> MonthStart('01/01/2012')

-Rob

Anonymous
Not applicable
Author

Hi Rob,

Certainly these functions are quite different, I've never said they are the same.  The month() function returns just a month name(number) from Jan(1) to Dec(12), while the monthstart() is the full date which can be formatted in any way.  So, month() often can be repalced with monthstart() with the appropriate formatting ('MMM'), at least for the presentation purpose, but not the other way around.
If Jayadevan V wants just the month name, any of these function can be used.  If he wants month and year, month() can't be used but monthstart() can.  Personally, I prefer using this for months:
date(monthstart(DateField),'MMM-YY') as MonthYear

Regards,
Michael