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.

Saurav Dhyani


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 - 

Dynamics 365 Business Central 2021 release wave 2 (BC19) Released.

Hi Readers, As we all were expecting Microsoft have Released Business Central 2021 Release Wave 2 Today a.k.a BC19. In this article we will see what all is announced with the General Availability.  Starting Today Customers & Partners can start using Business Central 19. #msdyn365bc #bc19

Error After Restore SQL Backup of NAV 2013 Database

Hi all, we are facing a conman issue during restoring a SQL Database backup restored for NAV 2013. While Trying to run object from Object Designer we get below listed error (even the service is configured properly) - --------------------------- Microsoft Dynamics NAV Development Environment --------------------------- There are no NAV Server instances available for this database. You must ensure that a NAV Server instance is running and is configured to use the database before you perform this activity. --------------------------- OK    ---------------------------