axapta - Datepart function error in Microsoft Dynamics SQL -
i trying perform sql query in microsoft dynamics ax2012, output year delivery date using datepart function.
i have created class "custrerportdemo" in aot, , while attempting perform query, query out year field "deliverydate" in table "salestable". encountered error prompts:
variable datepart has not been declared
i understood datepart function call in sql , shouldnt need declared. hence, wondering why , how rectify issue? trying show year delivery date.
therefore, if date 13/06/2016, resultant query result 2016 or 16. have attached following code. please help.
public void processreport() { custtable custtable; salestable salestable; //select customers while select * custtable { //clear temporary table custreportrdptmp.clear(); //assign customer account , name custreportrdptmp.custaccount = custtable.accountnum; custreportrdptmp.name = custtable.name(); //select count of invoiced sales order of customer select count(recid) salestable salestable.custaccount == custtable.accountnum && salestable.salesstatus == salesstatus::invoiced; custreportrdptmp.salesorderinvoicecount = int642int(salestable.recid); //new column display paymentmode select paymmode salestable salestable.paymmode == custtable.paymmode; custreportrdptmp.payment = salestable.paymmode; //new column display salesamounttotal drawing different table using join statement select smmsalesamounttotal salestable; custreportrdptmp.salesamt = salestable.smmsalesamounttotal; //new column display month delivery date select datepart("yyyy", deliverydate) year // extract single value year , month deliverydate in salestable salestable /* payment in (select count(payment) salestable salestable.custaccount == custtable.accountnum &&*/ //insert in temporary table buffer custreportrdptmp.insert(); } }
edited code:
select firstonly deliverydate salestable salestable.custaccount == custtable.accountnum; //get year date custreportrdptmp.datetimestamp = year(salestable.deliverydate);
result shown:
x++ select statement not sql , should not assume or sql functions available in x++; not!
there are date functions, 1 search called year.
it not belong in select though:
select firstonly deliverydate salestable; y = year(salestable.deliverydate);
Comments
Post a Comment