sql server - Dynamics AX 2012: Conversion failed when converting date and/or time from character string -


in ax have several entities. when try post unposted timesheets works fine entities except of 1 i'm getting sql error: "conversion failed when converting date and/or time character string"

the call stack below:

enter image description here

in highlighted method see cannot find sourcedocumentheader in accountdistribution table, accountingdate empty.

has experienced same problem , knows how solve it? strange me because other entities works ok.

thanks.

the technical explanation of seeing part of code generates invalid sql, looks me if have problem setup.

if run date2str on empty date returns empty string. please try in job , see empty string in infolog.

static void testemptydate(args _args) {     accountingdate _date;     ;     info(date2str(_date, 321, 2, 3, 2, 3, 4, dateflags::none)); } 

that gets concatenated in method updatedistributionsforevent generate sql statement:

sqlstatementtext = strfmt('update t1 set accountingevent=%1,recversion=%2 accountingdistribution t1 (index(i_7452sourcedocumentheaderidx)) cross join sourcedocumentline t2 ', _accountingeventrecid, xglobal::randompositiveint32());  sqlstatementtext += strfmt('where (((t1.partition=%1) , (t1.accountingevent=0) , (t1.accountingdate={ d\'%2\'})) , (t1.sourcedocumentheader=%3)) , ', getcurrentpartitionrecid(), sqldate, _sourcedocumentrecid); sqlstatementtext += strfmt('((t2.recid=t1.sourcedocumentline) , (t2.accountingstatus=%1 or t2.accountingstatus=%2)) , (t2.partition=%3)', enum2int(sourcedocumentlineaccountingstatus::completed), enum2int(sourcedocumentlineaccountingstatus::canceled), getcurrentpartitionrecid()); 

where t1.accountingdate={ d\'%2\'} relevant part generates t1.accountingdate={ d''} in sql string.

if try running

select  {d''} 

in sql

msg 241, level 16, state 3, line 1 conversion failed when converting date and/or time character string.

because empty string cannot parsed date.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -