Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Calendar dynamically should Take current year +1

Hi All,

i want to generate calendar to show current Year +1  ,how to do this in code.

for some Audit Reason they will upload future year data in advance ,it should be dynamic

LET Start = num(makedate(2014,1,1));

LET End =num(yearend(today()));

LET NumOfDays = End - Start + 1;

Date_src:

LOAD

$(Start) + Rowno() -1 as T_DateId

AUTOGENERATE $(NumOfDays);

Calendar:

LOAD

T_DateId as DateId,

T_DateId as Day,

year(T_DateId)*100+month(T_DateId) as  MonthId,

year(T_DateId)*100+ceil(month(T_DateId)/3) as  QuarterId,

month(T_DateId) as  Month,

// dual(month(T_DateId) & '-' & year(T_DateId), year(T_DateId) & num(month(T_DateId), '00')) as  MonthYear,

dual(month(T_DateId) & '-' & Date(T_DateId,'YY'), year(T_DateId)*100+month(T_DateId)) as  MonthYear,

// dual(Date(T_DateId,'YY')&'-'&month(T_DateId), year(T_DateId)*100+month(T_DateId)) as  MonthYear_YYMMM,

year(T_DateId) as  Year,

'Q' & ceil(month(T_DateId)/3) as  Quarter,

// dual('Q' & ceil(month(T_DateId)/3) & '-' & year(T_DateId), year(T_DateId) & ceil(month(T_DateId)/3)) as  QuarterYear,

dual(Date(T_DateId,'YY ')&'Q' & ceil(month(T_DateId)/3) , year(T_DateId) & ceil(month(T_DateId)/3)) as  QuarterYear,

Year(Today())-Year(T_DateId) as Year_Age,

(Year(Today())-Year(T_DateId))*12+(Month(Today())-Month(T_DateId)) as Month_Age,

(Year(Today())-Year(T_DateId))*12+(ceil(month(Today())/3)-ceil(month(T_DateId)/3)) as Quarter_Age

RESIDENT Date_src

;

Drop Table Date_src;

//DROP Table Calendar;

1 Solution

Accepted Solutions
Mark_Little
Luminary
Luminary

Hi,

Have you looked at the AddYears() function?

AddYears(Date,1) would add one year to the date field.

Mark

View solution in original post

2 Replies
Mark_Little
Luminary
Luminary

Hi,

Have you looked at the AddYears() function?

AddYears(Date,1) would add one year to the date field.

Mark

Not applicable
Author

Hi Mark,

AddYears(yearend(today()),1)  resolved issue

Thanks for your Suggestion.