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

Getting the last day of the month from year and month

Hello everyone, 

I hope you all are having a great day!

I have a column (eg: 2021001) from which I can extract year and month.

And I would like to get the last day of Jan 2021 like 01/31/2021. 

Is there a way to get the last date of the month from Year and Month? 

Thank you!

Labels (1)
1 Solution

Accepted Solutions
stevejoyce
Specialist II
Specialist II

ok,  then try this, replace in brackets your extraction logic.

date(monthend(makedate(<year>, <month>)),'MM/DD/YYYY')

View solution in original post

5 Replies
stevejoyce
Specialist II
Specialist II

monthend() will give you this.

you need to pass a date into this.  you can use date# to convert your string to a date:

 

date(monthend(date#('20210102', 'YYYYMMDD')),'MM/DD/YYYY')

su_pyae
Creator
Creator
Author

Hi, 

 

the data I have is not date. I can only extract Year and Month from it. 

stevejoyce
Specialist II
Specialist II

ok,  then try this, replace in brackets your extraction logic.

date(monthend(makedate(<year>, <month>)),'MM/DD/YYYY')

su_pyae
Creator
Creator
Author

Thank you!

I was able to use similar formula to solve the issue.

MonthEnd(MakeDate(Num#([Year_Col]), Num#(Right(MaxString(Col_2), 2))))

stevejoyce
Specialist II
Specialist II

Great.  Yes that's the same thing i posted only i wrapped in a date function at the end.