Remove days from Date in D365FO
Bonjour,
In this short article, we will see how we could remove days from a date in D365FO. c’est à dire change 31-01-2022 to 01-202.
public static void main(Args _args)
{
TransDate myDate = today();// Date to be converted to String
str dateString; // variable to hold the converted date
str trimedDate;
dateString = date2Str(myDate,231,
DateDay::Digits2,
DateSeparator::Hyphen, // separator1
DateMonth::Digits2,
DateSeparator::Hyphen, // separator2
DateYear::Digits4
);
trimedDate = subStr(dateString,1,7);
info(strFmt("%1",dateString));
info(strFmt("%1",trimedDate));
}