Personalized Community is here!
Quickly customize your community to find the content you seek.
Have questions on moving to the cloud? Visit the Dynamics 365 Migration Community today! Microsoft’s extensive network of Dynamics AX and Dynamics CRM experts can help.
2022 Release Wave 1 PlanDynamics 365 release plan for the 2022 release wave 1 describes all new features releasing from April 2022 through September 2022.
2022 release wave 1 plan
The FastTrack program is designed to help you accelerate your Dynamics 365 deployment with confidence.
FastTrack Community | FastTrack Program | Finance and Operations TechTalks | Customer Engagement TechTalks | Upcoming TechTalks | All TechTalks
Dynamics AX 2009, I want to add a range to a date field (Field name - EndDate) in Query such that it fetches only those records where that 'EndDate' falls in the current month. I don't think I can do that in the AOT object as such, but should be able to code it in the init() method.
The function MthOfYr(systemdateget()) actually gets me close to what I want. I get the numeric value of the month, but still not clear on how do I actually put it in setting the range. Can someone plz help?
I believe this can help
I was actually expecting a logic such as MthOfYr(endDate) == MthOfYr(systemdateget())
but If thts difficult, the one you mentioned is a fair option as well. Can that be put in the properties window of the range or have to write it in method?
In code, you could use dateStartMth() and dateEndMth() together with SysQuery::queryRange().
But there is an easier way that can be use directly in AOT: monthRange(). Please note that functions from SysQueryRangeUtil class must be enclosed in brackets when used in query ranges - e.g. (monthRange()).
look at class SysQueryRangeUtil
public static str monthRange(int relativeMonthsFrom = 0, int relativeMonthsTo = 0)
currentDateTime = DateTimeUtil::applyTimeZoneOffset(DateTimeUtil::getSystemDateTime(), DateTimeUtil::getUserPreferredTimeZone());
dayValue = DateTimeUtil::day(currentDateTime) - 1;
monthStartDate = DateTimeUtil::addDays(currentDateTime, -dayValue);
DateTimeUtil::date(DateTimeUtil::addDays(DateTimeUtil::addMonths(monthStartDate,relativeMonthsTo +1), -1)));
in your aot Range (monthRange(-1,0))
It can't be put in properties window
above solution suggested by Oleg, can be used using Query object in init() method
I think solution provided by Oleg is the best solution you have for your requirement
Please verify and let us know if you have more details..
it worked absolutely fine. It was short and simple.. :)
Yes Nitesh....you are right. It worked well.
Thanks Dick and Martin as well for your comments.
The solution suggested by Martin Dráb and Dick Wenning works perfectly:
Business Applications communities