I shouldn’t have any results when i run it for the specific arrangementId because the dates are earlier than today, but I get two results. The actual query select shows the following, which is including the records because it is missing quotes around the actual dates. Any one know how to get this to work correctly, I haven’t found anything online that works?
SQL Select for query:
Query DBS_SF_AssetQuery object 569d9bd0: SELECT * FROM DBS_SF_AssetView(DBS_SF_AssetView_1) WHERE ((((DBS_SF_AssetView_1.ArrVerElementModifiedDateTime > 11/26/2014) || (DBS_SF_AssetView_1.EndDate > 11/26/2014)))) AND (((Status != 5))) AND (((versionStatus != 0))) AND ((DBS_SF_AssetView(DBS_SF_AssetView_1).ArrangementId = N’AG0000000037’))
I get “String value cannot be converted to date value in the where clause. Try using the conversion function.” when using queryvalue().
When I try: queryValue(date2str(today(),213,DateDay::Digits2,DateSeparator::Slash,DateMonth::Digits2,DateSeparator::Slash,DateYear::Digits4,DateFlags::None))
I get the select without the quotes and same results as original post:
SELECT * FROM DBS_SF_AssetView(DBS_SF_AssetView_1) WHERE ((((DBS_SF_AssetView_1.ArrVerElementModifiedDateTime > 11/15/2014) || (DBS_SF_AssetView_1.EndDate > 11/15/2014)))) AND (((Status != 5))) AND (((versionStatus != 0))) AND ((DBS_SF_AssetView(DBS_SF_AssetView_1).ArrangementId = N’AG0000000037’))
I don’t know what format or ‘conversion functio’ it wants?
SELECT * FROM DBS_SF_AssetView(DBS_SF_AssetView_1) WHERE ((((DBS_SF_AssetView_1.ArrVerElementModifiedDateTime > “12/2/2014”) || (DBS_SF_AssetView_1.EndDate > “12/2/2014”)))) AND (((Status != 5))) AND (((versionStatus != 0))) AND ((DBS_SF_AssetView(DBS_SF_AssetView_1).ArrangementId = N’AG0000000037’))
All right, I wrote a runnable example to be able to test your issue. If you provided something like that yourself, maybe more people would take a look.
SELECT * FROM SalesTable(SalesTable_1)
WHERE (((SalesTable_1.CreatedDateTime < 03\12\2014)))
You asked how to add “missing quotes” and queryValue() does that, but it doesn’t seems to be a reasonable requirement. You see that there are no quotes in my solution and it works. Use date2strXpp() to convert dates for the purpose of extended query syntax (stick to queryValue() when setting range values normally) and don’t worry about quotes.
I will give that a try. Thanks, I’m still relatively new at this, I’ll provide a runnable example next time…I thought it was maybe just a simple syntax error I was making that wasn’t erroring on save in AX, but also not translating correctly at runtime. I really appreciate your help! I use this forum after searching out on the internet and not finding a solution, but I try. I’m traveling this week, but will try Monday and report back to let others know if it resolved my issue. Thanks again!
Just replace ‘myTable’ with your table name, ‘ModifiedDateTimeField’ and ‘EndDateField’ with your two date fields in your table and then ‘MyModDateValue’ and ‘myEndDateValue’ with the parameter or calculated date values you would like to use to compare the table date fields to.
Hopefully that helps somebody else. Thanks for your help Martin!