I am trying to pass a date range to a query and run the query using STRQMQRY. Is this possible?
The query runs automatically every month so it needs the date range for its select criteria changed automatically before the query is run.
&DATSEL = 'date'
CHGVAR VAR(&FROM) VALUE(&YYYY *CAT &MM *CAT '01')
CHGVAR VAR(&TO) VALUE(&YYYY *CAT &MM *CAT '99')
CHGVAR VAR(&QRYSLT) VALUE(&DATSEL *CAT ' *GE ' *CAT +
&QOTE *CAT &FROM *TCAT &QOTE *CAT +
&ND *CAT &DATSEL *CAT ' *LE ' *CAT +
&QOTE *CAT &TO *TCAT &QOTE)
STRQMQRY QMQRY(&QUERY) OUTPUT(*PRINT) QMFORM(&QUERY) +
ALWQRYDFN(*YES) SETVAR((QRYSELECT +
&QRYSLT) (COND1 &SEL1) +
(COND2 &SEL2) (COND3 +
&SEL3) (COND4 &SEL4) (COND5 &SEL5))
The program has just finished it's monthly run but the report I received from the query is the result of the saved select statement, it didn't use the calculated date range from the program. Did I do something wrong?
The query was created using STRQRY.
The query runs automatically every month so it needs the date range for its select criteria changed automatically before the query is run.
&DATSEL = 'date'
CHGVAR VAR(&FROM) VALUE(&YYYY *CAT &MM *CAT '01')
CHGVAR VAR(&TO) VALUE(&YYYY *CAT &MM *CAT '99')
CHGVAR VAR(&QRYSLT) VALUE(&DATSEL *CAT ' *GE ' *CAT +
&QOTE *CAT &FROM *TCAT &QOTE *CAT +
&ND *CAT &DATSEL *CAT ' *LE ' *CAT +
&QOTE *CAT &TO *TCAT &QOTE)
STRQMQRY QMQRY(&QUERY) OUTPUT(*PRINT) QMFORM(&QUERY) +
ALWQRYDFN(*YES) SETVAR((QRYSELECT +
&QRYSLT) (COND1 &SEL1) +
(COND2 &SEL2) (COND3 +
&SEL3) (COND4 &SEL4) (COND5 &SEL5))
The program has just finished it's monthly run but the report I received from the query is the result of the saved select statement, it didn't use the calculated date range from the program. Did I do something wrong?
The query was created using STRQRY.