Monday, July 1, 2019

Get Week start and end Date based on YEAR & Week number

class SAN_DEMO
{       
    /// <summary>
    /// Class return week start and end Date based on YEAR & Week number
    /// </summary>
    /// <param name = "_args">The specified arguments.</param>
    public static void main(Args _args)
    {
        TransDate   setDate, startDate, endDate;
        int i;
        Year yr     = 2019;
        int week    = 5;
        int weekGet;
        int weekdays;
       
        setDate     = mkDate(01,01,yr);
        i           = dayOfWk(setDate);
        if(i<7)
        {
            setDate = setDate + (7-i);
            weekGet = week-1;
        }
        weekdays    = weekGet * 7;
        startDate   =  (setDate + weekdays)-7;
        endDate     =  (setDate + weekdays)-1;

        Info(strfmt("Year %1",yr));
        Info(strfmt("Week %1",week));
        Info(strfmt("Week Date Start %1",startDate));
        Info(strfmt("eeWk Date End %1",endDate));
    }

}

No comments:

Post a Comment

Copy Markup charges while posting purchase invoice using X++

 Copy Markup charges while posting purchase invoice using X++ Class: Important: Code logic is just for Reference.  New class => Duplicate...