Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
rcandeo
Creator III
Creator III

How can I do this selection?

I have a macro used to select actual month and year in my application:

ActiveDocument.GetField("Month").Select ActiveDocument.Evaluate("date(addmonths(monthstart(today(1)),-1),'MM')")

It was working, till I defined my Month field properties to integer.

Can anyone help me fixing this function?

1 Solution

Accepted Solutions
Not applicable

I'm guessing this should work:

ActiveDocument.GetField("Month").Select ActiveDocument.Evaluate("date(addmonths(monthstart(today(1)),-1),'M')")


I did a quick test and 05 is different from 5. If I use your original expression, I can select months stored as 05. If I remove one of the Ms, it won't select 05, but it will select 5. I'd check how you're early months look, I'm guessing they don't have the leading zero.

View solution in original post

4 Replies
Not applicable

I'm guessing this should work:

ActiveDocument.GetField("Month").Select ActiveDocument.Evaluate("date(addmonths(monthstart(today(1)),-1),'M')")


I did a quick test and 05 is different from 5. If I use your original expression, I can select months stored as 05. If I remove one of the Ms, it won't select 05, but it will select 5. I'd check how you're early months look, I'm guessing they don't have the leading zero.

rcandeo
Creator III
Creator III
Author

It worked, but I am worried about last three years of the month: 10, 11, 12. Do You Think will it work?

Not applicable

Yes, those would have worked with either expression. One M means one number for the earlier months, but would still display as two numbers for October and later.

You could probably amend your expression to select a later month, by changing the parameter of the addmonths function to test it out. EDIT: I did addmonths(date, 5) for both MM and M and it selected 11.

rcandeo
Creator III
Creator III
Author

Forget, I've found a way to test and it worked again. Thank You