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

Can I select the range of dates using the calender object

Hi All,

I want to use one calender object to select the from date and the other calender object to select the to date. For example, as shown below if select 01/01/07 in "Date From" and 31/07/07 in the "Date To" then it should the date range from 01/01/07 to 31/07/07.

Some one please let me know how it can be done.

error loading image

15 Replies
Not applicable
Author

Hi There

You could add a button that runs the macro below, which will "reset" the variables back to the way you have them initialised..

sub reset_vars
set doc=ActiveDocument
set vars = doc.GetVariableDescriptions
doc.Variables("vStartDate").SetContent "39814", true
doc.Variables("vEndDate").SetContent "39854", true

set vars = nothing
set doc = nothing
end sub


You still need to "Clear" the other data though - and this can be achieved by another button with a Clear All action attached to it.

Not applicable
Author

Hi Graeme!

Many thanks for your suggestions. But I think there must be some other way to do the same. Please look into the document attached by Mr. Nick. In that document date fields are getting cleared without the help of macro. So there must of the other way to do so.

Hope Mr. Nick can answer for us.

Have attached Mr. Nick's document for your reference.

Not applicable
Author

At a guess, you're hardcoding the Start and End dates in the script ?

LET vDateMin = Num(MakeDate(2009,1,1));
LET vDateMax = Floor(MonthEnd(Today()));
LET vDateToday = Num(Today());

Not applicable
Author

Hi Graeme,

May be but I don't know. Is it the one creating problem here. It is hard coded just because it is getting retrieved from the master calender.

Do you think it is creating problem here.

Not applicable
Author

Yes in my opinion.

The only way to "clear" it, is either use Nik's method for calendar creation, or the buttons I described above....

Not applicable
Author

Check Document Event Triggers. I'm using OnAnySelect action to clear the Start/End Date variables by expression like this:

=if(len(GetFieldSelections(Date)), vStartDate)
=if(len(GetFieldSelections(Date)), vEndDate)


Check another Document Event Trigger for OnOpen Event also.