Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
karunaramteke
Contributor III
Contributor III

select dates 31 days months, 30 days and leap year

Hi all,

please help to get the following,

For 31 days   : date from 17th to 31st Oct'20 to be considered only. 

For 30 days months       : Date from 16th to 30th to be considered.

for February :  in leap year 15th to 29th, while in non-leap year 14th to 28th to be considered.

 

Please help me to get this or if any link is there by which I can get help.

Thank you in advance

Labels (1)
2 Replies
karunaramteke
Contributor III
Contributor III
Author

Hi all,

Anyone can help me it this.

 

 

MayilVahanan

Hi @karunaramteke 

Try like below

LET vDMNoOfYear =6;
LET vMaxDate = Num(Today()-1);
LET vMinDate = Num(YearStart(AddYears(Today(), -($(vDMNoOfYear)))));

Load *,
If(Month(CalDate)='Feb',
If(mod(Year(CalDate),4) = 0 and mod(Year(CalDate),100) <> 0 or mod(Year(CalDate),400) = 0,
if(Day(CalDate)>14,1), If(Day(CalDate)>13,1)),
if(Match(Month(CalDate), 'Jan', 'Mar', 'May', 'Jul', 'Aug', 'Oct', 'Dec'),
If(Day(CalDate)>16,1),
If(Day(CalDate)>15, 1))) as Flag,
Year(CalDate) as Year,
Day(CalDate) as Day,
Month(CalDate) as Month;
LOAD
Date($(vMinDate) + IterNo()-1) as CalDate
AutoGenerate 1
While $(vMinDate) + IterNo()-1 <= $(vMaxDate);

 

Select Flag and verify the values.. You can use flag in ur set analysis. 
Or instead of Flag, u can create another date field also.

Its depends on ur requirements.

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.