Hi,
I have a problem in a query value when i set the date field to the date dialog field value the query retrieves all data but when i set it to mkdate(31,1,2019) as an example it filters the data as needed
Here is my code
//ClassDeclaration
FromDate fromDate;
ToDate toDate;
DialogField dlgFromDate;
DialogField dlgToDate;
#define.CurrentVersion(1)
#localmacro.CurrentList
fromDate,
toDate
#endmacro
//Dialog
public Object dialog(Object _dialog)
{
_dialog.addGroup("@SYS74558");
dlgFromDate = _dialog.addFieldValue(typeid(FromDate),fromDate,"@SYS24050");
dlgToDate = _dialog.addFieldValue(typeid(ToDate),toDate,"@SYS14656");
return _dialog;
}
//getFromDialog
fromDate = dlgFromDate.value();
toDate = dlgToDate.value();
//buildPeriodQuery and add date range (here is the problem)
private Query buildPeriodQuery()
{
QueryBuildDataSource queryBuildDataSource;
QueryBuildRange queryBuildRange;
Query queryBuild;
;
queryBuild = new Query(this.query().pack());
queryBuildDataSource = queryBuild.dataSourceTable(tablenum(CustInvoiceJour));
queryBuildRange = SysQuery::findOrCreateRange(queryBuildDataSource, fieldnum(CustInvoiceJour, InvoiceDate));
queryBuildRange.value(queryRange(fromDate, toDate)); // When i set toDate = mkdate(31,1,2019) it works fine other wise it gets all data ignoring toDate value
info(queryBuildDataSource.toString());
return queryBuild;
}
and this is the query result
SELECT FIRSTFAST * FROM CustInvoiceJour
WHERE CustTable.AccountNum = CustInvoiceJour.OrderAccount
AND ((RefNum = 0))
AND ((InvoiceDate>={ts '2019-01-01 00:00:00.000'} AND InvoiceDate<={ts '2109-01-31 00:00:00.000'})) // it gets all data the filter of date as it does not exist
JOIN FIRSTFAST * FROM CustInvoiceTrans
WHERE CustInvoiceJour.SalesId = CustInvoiceTrans.SalesId
AND CustInvoiceJour.InvoiceId = CustInvoiceTrans.InvoiceId
AND CustInvoiceJour.InvoiceDate = CustInvoiceTrans.InvoiceDate
AND CustInvoiceJour.numberSequenceGroup = CustInvoiceTrans.numberSequenceGroup
Thanks in advance