Skip to main content

How DO I - Calculate Working and Nonworking Day in #MSDynNAV & #MSDyn365bc.

Hi Readers,

In Last article we understand how to setup Base Calendar in #MSDynNAV & #MSDyn365bc. 

In this article we will see how we can utilize base calendar to check Working and Non-Working Days based on Calendar. 

This is actually a question during last #bcopendiscussion from Shahid Ullah.

Question - How to find the Workings Days in a month or from a given date range?

For the Demo, I will create a Page which will allow user to input a Start Date and End Date.

And the Result after the calculation will be -

  • Total No. of Days between Date Range.
  • Working Days between Date Range.
  • Non-Working Days between Date Range.

To achieve that we can use the Base Microsoft "Calendar Management" Codeunit.

Calendar Management have a function - CheckDateStatus which will check Date Status based on a Base Calendar Code specified. 

This Function will provide the Date Status as Working or Non Working. The Example that we discussed is from Business Central 14 C/AL Version.

For Business Central AL, the base Microsoft code is changed.

In Business Central a new function is added -

  • IsNonworkingDay
    • This function requires a date input that you want to check with Customized Calendar Change Record.
  • To invoke this function we first need to setup the Customized Calendar Change record for which there is a function to SetSource.
    • SetSource Requires a Record from where calendar code need to be picked and a Record for Customized Calendar Change.

You Can download Source Code from GitHub.

C/AL Version

Extension Version

If you would like to have access to code You can download that from GitHub.

Hope you find the article useful. 

Let me know your views as comment to this article.

Regards,
Saurav Dhyani
http://www.sauravdhyani.com/

Comments

Popular posts from this blog

Send Mail with Attachment From Navision.

Hi all, We have seen how to save a report into PDF and how to send mail to a customer. Let's link these two post in one i.e. Mailing statement to a customer into PDF Format. This article is part of the Series. Please Refer  Table of Content here . If you have the old objects set let me brief you what I will be changing - 

BC 21 and Higher - PowerShell Cmdlet (Replacement of Business Central Administration).

Hi Readers, As discussed in last article about deprecating of Business Central Administration, there are few common actions that we use in administration till Business Central 20. For our on-prem customers, we will still require doing activities. As Microsoft suggest we need to start using PowerShell cmdlet.    Let's see how to do those via PowerShell, or Administration Shell. I will be keep adding commands as you comment to this article.

MSDYN365BC - Data Upgrade To Microsoft Dynamics 365 Business Central on premises.

Hi Readers, We have already talked about the number of steps for upgrading to Business Central on Premises from different NAV versions. After that article, I received multiple requests for an article which list down steps for Data Migration. In this article, we will discuss steps of data migration to MSDYN365BC (on-Prem) from NAV 2017. For this article, I am considering a Cronus Demo Database without any customization. For an actual upgrade project, we will have to complete object merge using compare and Merge process. After the Merge Process, the next step is data migration. Let's discuss those steps. Direct Upgrade to Microsoft Dynamics 365 Business Central (on-Prem) is from following versions - 1. NAV 2015. 2. NAV 2016. 3. NAV 2017. 4. NAV 2018.