We have created a customization within D365 Finance. We have a Data view created and underneath it, is a class method. Code mentioned below. This program should return values as <”1stMay2023” when extracted in May 2023 and then in June as <”1stJune2023” and so on. However it instead returns value as <”1st Mar 2023” which is weird. If we re-compile the code (without any changes) and re-run it, it works fine. Thereafter two-three attempts later, it again starts to throw unwarranted result as <”1st Mar 2023”.
Can someone help identify what is wrong with the code?
Is someone else also facing a similar issue in D365 Finance?
public static class MTVoyageClass
{
/// <summary>
/// Returns a string which can be used as range for Accounting date upto last month transactions.
/// </summary>
[QueryRangeFunction]
public static str lessthanLastMonth()
{
int days ;
utcdatetime currentDateTime;
currentDateTime = DateTimeUtil::applyTimeZoneOffset(DateTimeUtil::getSystemDateTime(), DateTimeUtil::getUserPreferredTimeZone());
days = DateTimeUtil::day(currentDateTime)-1;
return SysQueryRangeUtil::lessThanDate(-days);
}
}