
HI all,
I have an issue in using QueryBuildRange. I need to apply date range in query build Range expression.
As you can see below I want to add No of Days( Integer) in TransDate field of Datasource in the range expression itself. I really need to know how can I achieve this as with the existing code because it is concatenating rather than adding ( i.e it is accepting as a string in strfmt).
Can you please suggest a standard approach?
queryBuildDataSource = query.addDataSource(tableNum(ABC));
queryBuildRange = queryBuildDataSource.addRange(fieldnum(ABC, XYZ));
queryBuildRange.value(strFmt('((%1 == %2) || ((%1 == %3)))',
fieldStr(ABC, XYZ),
any2int(XYZ::Delivered),
any2int(XYZ::ToBeReturned)));
*/
GracePeriod = CustParameters::find().DEFTable; // Integer value(No of days)
queryBuildRange.value(strFmt('(((%1 == %2) && (%4 <= %5)) || ((%1 == %3) && ((%4+%6) <= %5)))',
fieldStr(ABC, iop),
any2int(XYZ::Delivered),
any2int(XYZ::ToBeReturned),
fieldStr(ABC,Transdate) ,
date2StrXpp(latestDueDate),
any2date(GracePeriod)));
queryBuildRange.toString();
info(queryBuildRange.toString());
queryBuildRange.status(RangeStatus::Locked);
chooseLines = new QueryRun(query);
Thanks in advance.
*This post is locked for comments
I have the same question (0)Hi Deepak
To create the range you can use the SysQuery::Range method (https://msdn.microsoft.com/en-us/library/sysquery.range.aspx)
To add the days I would suggest ussing the DateTimeUtil::addDays method
utcDateTime now = DateTimeUtil::getSystemDateTime();
qbds.addRange(fieldNum(Table, StartDate))
.value(SysQuery::range(now, DateTimeUtill::addDays(now, GracePeriod));
Regards,
Koen