How to filter in execute query by Date range value?

旧城冷巷雨未停 提交于 2019-12-11 12:13:21

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!