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

MakeDate - Selecting Month & Year

Hi,

I'm trying to show a date based on a selected month.  If "Oct 2015" is selected, I want to return the value 30/11/2014.

I have created the below formula, but it doesn't work when I add a "+1" to the month line.  Any thought?

=MakeDate(
Year(Calendar.MonthName)-1,
Month(Calendar.MonthName),
Day(MonthEnd(Calendar.MonthName)))

1 Solution

Accepted Solutions
sunny_talwar

Try this:

=MakeDate(
Year(Calendar.MonthName)-1,
Month(AddMonths(Calendar.MonthName, 1)),
Day(MonthEnd(AddMonths(Calendar.MonthName, 1)
)))

I think the issue is that Nov only has 30 days and the previous expression was calculating the end of day for Oct which is 31 and expression fails

View solution in original post

3 Replies
sunny_talwar

Try this:


=MakeDate(
Year(Calendar.MonthName)-1,
Month(AddMonths(Calendar.MonthName, 1)),
Day(MonthEnd(AddMonths(Calendar.MonthName, 1)
)))

nwilliams
Contributor
Contributor
Author

So I now have the below, but this simply returns "-"

=MakeDate(
Year(Calendar.MonthName)-1,
Month(AddMonths(Calendar.MonthName,1)),
Day(MonthEnd(Calendar.MonthName)))

sunny_talwar

Try this:

=MakeDate(
Year(Calendar.MonthName)-1,
Month(AddMonths(Calendar.MonthName, 1)),
Day(MonthEnd(AddMonths(Calendar.MonthName, 1)
)))

I think the issue is that Nov only has 30 days and the previous expression was calculating the end of day for Oct which is 31 and expression fails