Monday, April 22, 2024

Find smallest date from a set of dates using X++

ListEnumerator  listEnumerator;
list listDates = new  list(Types::Date);

listDates.addEnd(Date1);
listDates.addEnd(Date2);
listDates.addEnd(Date3);
listDates.addEnd(Date4);

TransDate lowestDate = dateMax();

if (listDates.elements() > 0)
{
	listEnumerator = listDates.getEnumerator();
	while (listEnumerator.moveNext())
	{
		if(listEnumerator.current() <= lowestDate && listEnumerator.current() != dateNull())
		{
			lowestDate = listEnumerator.current();
		}
	}
}

if(lowestDate != dateNull() && lowestDate != dateMax())
{
	info(lowestDate);
}

No comments:

Post a Comment

Table browser URL in D365FO

Critical Thinking icon icon by Icons8