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

VIEW SERVER STATE permission on SQL Server?

Hi all, Sometime While trying to Login into a database we face an error message as shown below. --------------------------- Microsoft Dynamics NAV Classic --------------------------- You cannot start Microsoft Dynamics NAV Classic because you do not have the VIEW SERVER STATE permission on SQL Server. Contact your system administrator. --------------------------- OK    ---------------------------

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.

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 -