Thursday, 6 February 2014

How to get balance in a year for a customer

static void PreviousYearBalance(Args _args)
{
int nowyear;
    transdate fromdate;
    transdate  enddate;
    CustTrans custtransloc;

    nowyear = year(today())-1;

    fromdate = str2DateDMY(strFmt("1/1/%1", nowyear));
    enddate = today();

    select sum (AmountMST) from custtransloc

        where custtransloc.AccountNum == "2014" &&
              custtransloc.TransDate       >= fromdate        &&
              custtransloc.TransDate       <= enddate ;

    info(strFmt("%1",custtransloc.AmountMST));
    //info(strFmt("%1",todate));
}

No comments:

Post a Comment