Qlik Community

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Join “Do More With Qlik” with Mike Tarallo to get a first-hand look at the New Authoring Experience, June 29th: REGISTER HERE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Convert Date to Month and Year

I have date column with Date format as 01-01-2017.I want to get the month and Year out of this and I tried Month(Datefield) ,Year(Datefield) but it is not working.Can anyone help me here ?

5 Replies
Not applicable
Author

Hello,

Try as below:

Month(Date#(Datefield, 'DD-MM-YYYY'))

Year(Date#(Datefield, 'DD-MM-YYYY'))

BR,

Kuba

vishsaggi
Champion III
Champion III

Try this :

= Month(Date#('01-01-2017', 'DD-MM-YYYY'))

= Year(Date#('01-01-2017', 'DD-MM-YYYY'))

sunny_talwar

You can also read about Dates here:

Get the Dates Right

Why don’t my dates work?

Alex-Kayanga
Contributor II
Contributor II

date(MonthStart(date(["YOUR DATA FILED NAME"],'YYYY/MM/DD')),'MMM-YYYY')

shamiul_islam
Contributor III
Contributor III

If you need the Month and Year simultaneously in your file you can create Day,Month,Year separately in your script like this:

LET vToday=num(today());
LET vMinDate=42370;
LET vMaxDate=num(today());

// Temporary Table

TempCal:
LOAD
date($(vMinDate) +RowNo()) as TempDate
AutoGenerate
$(vMaxDate)-$(vMinDate);

//******************** MASTER CALENDAR**********************
MasterCalendar:


LOAD
TempDate as TRDate,

Year(TempDate) AS Year,
Month(TempDate) as Month,
day(TempDate) as MDay,
Week(TempDate) as Week,
WeekName(TempDate) as WeekName,
Date(MonthStart(TempDate),'YYYYMM') as YearMonth
Resident TempCal;

DROP Table TempCal;

Thanks.