Thursday, January 7, 2016

Get the days that are not holiday or weekend

Hi all,
Today I posted how you can Get the days that are not holiday or weekend.

// Get the days that are not holiday or weekend
//-----Define Local Parameters---------
{
Var Name DataType Subtype Length
No StartDate Date
No EndDate Date
//-----Define Return type---------
Name WorkDays
ReturnType Integer
//-----Define Local variabls---------
Name DataType Subtype Length
DateRec Record Date [where Table ID: 2000000007]
HolidayRec Record Shop Calendar Holiday     [where Table ID: 99000753]
}
//-----Define Function---------
GetWorkingDays(StartDate : Date;EndDate : Date) WorkDays : Integer
// Strat ---------------------->>
WorkDays := 0;
DateRec.RESET;
HolidayRec.RESET;

DateRec.SETRANGE("Period Type",DateRec."Period Type"::Date);
DateRec.SETRANGE("Period Start",StartDate,EndDate);
DateRec.SETRANGE("Period No.",1,5);  // Get only weekdays
IF DateRec.FINDFIRST THEN
  REPEAT
    IF NOT HolidayRec.GET('HLP',DateRec."Period Start") THEN
      WorkDays += 1;
  UNTIL DateRec.NEXT = 0;
EXIT(WorkDays);
// End <<------------------------


Thanks & Best Wishes
Binesh Singh Rajput
(MCP, MS, MCTS)


No comments:

Post a Comment

Popular Posts