Wednesday, April 23, 2014

Finding current, previous and next week period through X++

static void Example_date(Args _args)
{
    TransDate   cwkstartDate,cwkEndDate;
    TransDate   lwkstartDate,lwkEndDate;
    TransDate   nwkstartDate,nwkEndDate;
    TransDate   d;
    ;
    d = systemDateget();
    cwkstartDate = Global::dateStartWk(d);
    cwkEndDate   = Global::dateEndWk(d) - 1;
    info(strfmt("Current StartDate: %1 and EndDate: %2",cwkstartDate,cwkEndDate));
    lwkstartDate = (Global::dateStartWk(d) - 7);
    lwkEndDate   = (Global::dateEndWk(lwkstartDate)) - 1;
    info(strfmt("Lastweek StartDate: %1 and EndDate: %2",lwkstartDate,lwkEndDate));
    nwkstartDate = (Global::dateStartWk(d) + 7);
    nwkEndDate   = (Global::dateEndWk(nwkstartDate)) - 1;
    info(strfmt("Nextweek StartDate: %1 and EndDate: %2",nwkstartDate,nwkEndDate));
}

No comments:

Post a Comment