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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to select a date range with a macro

I have created a macro, which selects two variables and attempts to select a date range in a field, but it does not work.

Here is the macro:

sub DataBetweenSelectedDate()

set FD = ActiveDocument.Variables("FromDate") '' variable for Initial from date

FrmDtt=(FD.GetContent.String)

set TD = ActiveDocument.Variables("ToDate") '' variable for Initial to date

ToDtt=(TD.GetContent.String)

FrmDate=">=" & Day(FrmDtt) & "/" & month(FrmDtt) & "/" & year(FrmDtt)

msgbox FrmDate

ToDate ="<=" & Day(ToDtt) & "/" & month(ToDtt) & "/" & year(ToDtt)

msgbox ToDate

toSelect = FrmDate   &   ToDate

msgbox toSelect

ActiveDocument.Fields("Start_Date").Select toSelect ''

end sub

The message boxes in order state: '>=1/12/2010', '<=31/12/2010', '>=1/12/2010<=31/12/2010'

Does anyone know why this does not select anything in the Start_Date field?

1 Reply
deepakk
Partner - Specialist III
Partner - Specialist III

hi,

Instead of Macro you can use the required the date selection in expression.

Please find a sample attachment for the same.

Deepak