How to get Days from Month in D365 BC

Get Days from Month in D365 BC:

(I) Create procedure or function in a object (like page, report, table and code unit).

(II) Define parameters and return value in procedure as shown below-

Define parameters and return value in procedure

(III) When the above procedure or function is call then it will give total number of days in month.

(IV) If GetMonth := 3; and GetYear := 2021; then system gives 31 days.

Source Code:

codeunit 50001 “Custom Functions-01”
{
    trigger OnRun()
    begin
 
    end;
 
    local procedure HowToGetDaysInMonth(GetMonth: Integer; GetYear: Integer): Integer
   var
        MODValue: Decimal;
NoOfDays: Integer;
    begin
        GetMonth := 3; // Assign value to variable
        GetYear := 2021; // Assign value to variable
        NoOfDays := 0;
 
        IF GetMonth IN [1, 3, 5, 7, 8, 10, 12] THEN
            NoOfDays := 31;
 
        IF GetMonth IN [2] THEN BEGIN
            MODValue := GetYear MOD 4;
            IF MODValue = 0 THEN
                NoOfDays := 29
            ELSE
                NoOfDays := 28;
        END;
 
        IF GetMonth IN [4, 6, 9, 11] THEN
            NoOfDays := 30;
        EXIT(NoOfDays);
    end;
 
}

Create and Apply Template Feature in D365 BC in Masters
Create Export to Excel Report in Business Central
How to create a New Instance in Dynamics 365 BC, Business Central
How To Import License File In Business Central D365 On-premises
Set Up Goods and Services Tax Posting– Microsoft Docs

Leave a Reply