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

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Making a Year Month Column


Hello, please can someone tell me how to make a year month column

I am bringing in a field from excel called Anticipated Launch date.

An example of a date being brought in is Apr-15

I want to create a new column with year month in it so would want the above to show as

2015-4

Please can someone help with this issue.

Thank you

Kind Regards

13 Replies
simondachstr
Specialist III
Specialist III

Date(date#([Anticipated Launch date],'MMM-YY'),'YYYY-M)

Date# evaluates a string into a calendar format.

Date formats a calendar value.

Not applicable
Author

Thank you for your help Martin but I still have an issue with it.  I am adding this date to a column with a date already in it.  They look like the same format but one is right justified and one left:

eg

         2014-6

         2014-5

2014-5

2014-8

Please could you assist in getting them the same.  Thanks

MK_QSL
MVP
MVP

Load

  [Launch Date],

  Date(MonthStart(Date#([Launch Date],'MMM-YY')),'YYYY-M') as YearMonth

Inline

[

  Launch Date

  Apr-14

  Apr-15

  Jun-14

  Jun-16

];

simondachstr
Specialist III
Specialist III

Anything that is left aligned is probably formatted as text, right a aligned as number/date.

Make sure the column already with a date in it also has the correct calendar format.

Anonymous
Not applicable
Author

Looks like one is a string and not a numeric date, try something like :

Date(date#([YourDateField],'YYYY-M)','YYYY-M')

simondachstr
Specialist III
Specialist III

Why MonthStart()?

MK_QSL
MVP
MVP

Even without MonthStart() it will work...

Not applicable
Author

Hi Martin

The other date comes in like this

convert(varchar,year([PstngDate])) + '-' +  convert(varchar,month([PstngDate])) as yearmonth

Im not sure how to convert this back to match the other one.

......... and apologies,,, im very new to all this!!

Anonymous
Not applicable
Author

Emma

Try something like

     date([PstngDate] ,'YYYY-M')      as yearmonth ,