AX query to find the 2nd max date

hi i want to find the 2nd max date,

i write query lik this,

select maxof(invoicedate) from cust.InvoiceDate where cust.invoicedate < (select maxof(invoicedate) from cust);

it shows error, can anyone pls help me…

pls anyone help me…

thanx in advance… :slight_smile: :slight_smile:

hi,

try like this it will work…

static void Job26(Args _args)
{
custinvoicejour c;
int i=0;
;

while select c order by c.InvoiceDate desc
{
i++;
if(i == 2)
{
info(strfmt(’%1’,c.InvoiceDate));
break;
}
}
}