General X++ Development

How do I select records between two dates in X++?

Asked by Sunny Vasty· Aug 13, 2026· 1 answers

How do I select records between two dates in X++?

SSunny Vasty75 reputation · answered Aug 13, 2026

Use normal comparison operators.

X++
TransDate fromDate = mkDate(1, 1, 2026);
TransDate toDate   = mkDate(31, 1, 2026);
CustTrans custTrans;

while select custTrans
    where custTrans.TransDate >= fromDate
       && custTrans.TransDate <= toDate
{
    info(custTrans.Voucher);
}

For a utcdatetime field, use utcdatetime values instead of date values so you do not accidentally lose the time portion.