问题
I have to made a Query in executeQuery
, and I have to filter by date field,
my code is :
public void executeQuery()
{
utcDateTime dateUTC, datenullUTC;
query q = new Query();
QueryBuildRange qbr;
QueryBuildDataSource qbds ;
QueryRun queryRun;
dateUTC = DateTimeUtil::newDateTime(_dateValue, 0, DateTimeUtil::getCompanyTimeZone());
qbds = q.addDataSource(tableNum(MCRCustCategory) );
qbds.addRange(fieldNum(MCRCustCategory, ValidTo)).value(strFmt ("> %1", dateUTC) );
queryRun = new QueryRun (q);
super();
}
In my init
I call the executeQuery, but don't filter in my Form.
How to use the date in the Range ?
Thanks all,
enjoy!
回答1:
You use a table which use date effective. You assume you have to do the selection yourself, this is not true.
Use this instead:
public void executeQuery()
{
this.queryBuildDataSource().validTimeStateAsOfDate(_dateValue);
super();
}
If you have an interval, use this instead:
this.queryBuildDataSource().validTimeStateDateRange(fromDate, toDate)
Your code as provided in the question does not do anything at all, as the form does not use the query you build. You buildt the wrong query anyway!
This blog post explains it concisely.
来源:https://stackoverflow.com/questions/34020829/how-to-filter-in-execute-query-by-date-range-value