Quantcast
Channel: Microsoft Dynamics AX Forum - Recent Threads
Viewing all articles
Browse latest Browse all 72043

Problem with date format in query

$
0
0

Hello,

I use this code to init my query :

    query               = new Query();

    qbdsProjTable       = query.addDataSource(tablenum(ProjTable));
    qbrContractType     = qbdsProjTable.addRange(fieldnum(ProjTable, AVA_FPContractType));
    qbrContractType.value(SysQuery::valueNot(#LocationFinanciere));
    qbrSalesType        = qbdsProjTable.addRange(fieldnum(ProjTable, AVA_SalesType));
    qbrSalesType.value(QueryValue(AVA_SalesTypeEnum::Contract));
    qbrContractResilie  = qbdsProjTable.addRange(fieldnum(ProjTable, AVA_ContratResiliation));
    qbrContractResilie.value(QueryValue(NoYes::Yes));

    qbDate.value(strfmt('((%1 >= %4) OR (%2 >= %4) OR (%3 >= %4))',
        fieldstr(ProjTable, AVA_ContratDateProrogation),
        fieldstr(ProjTable, AVA_ContratDateFinRenego),
        fieldstr(ProjTable, AVA_ContratDateResiliation),
        QueryValue(dend)));

    queryRun    = new SysQueryRun(query);

The syntax is good but i don't have the good number of recording.

When i use the debogger, the query value is :

SELECT * FROM ProjTable WHERE ((NOT (AVA_FPContractType = N'LF'))) AND ((AVA_SalesType = 1)) AND ((AVA_ContratResiliation = 1)) AND ((((AVA_ContratDateProrogation >= "30/11/2012") OR (AVA_ContratDateFinRenego >= "30/11/2012") OR (AVA_ContratDateResiliation >= "30/11/2012"))))

this give me :17333 records. this is the wrong result

But in SQL Management, when i use :

SELECT * FROM ProjTable WHERE ((NOT (AVA_FPContractType = N'LF'))) AND ((AVA_SalesType = 1)) AND ((AVA_ContratResiliation = 1)) AND ((((AVA_ContratDateProrogation >= {ts '2012-11-30 00:00:00.000'}) OR (AVA_ContratDateFinRenego >= {ts '2012-11-30 00:00:00.000'}) OR (AVA_ContratDateResiliation >= {ts '2012-11-30 00:00:00.000'}))))

this give me : 11478 records, and this is the good result.

Is it possible, in AX 4.0, to convert the date dend to a SQL fomat ?

Thanks.


Viewing all articles
Browse latest Browse all 72043

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>