Hello guys.
I have some trouble using CalcDateBOC and CheckDateStatus functions in codeunit 7600. I am not sure how to use them.
How can I calculate what is the last working date in a month?
For example, if customer validates payment date to be 12.1.2017. then in a field "Last date" it should validate 31.1.2017..
Thanks
0
Answers
CALCDATE ('<CM>', Today).
Blog - rockwithnav.wordpress.com/
Twitter - https://twitter.com/RockwithNav
Facebook - https://facebook.com/rockwithnav/
Hope you had understood.
Blog - rockwithnav.wordpress.com/
Twitter - https://twitter.com/RockwithNav
Facebook - https://facebook.com/rockwithnav/
For example, for January 2017 it is 31st but for July 2016 it is not 31st but 29th.
You need a calender or an assuption to determine the working days. Your first step should be to find the last date of the month using <CM> thing, and then you should step backwards with <-1D> and check if the current date is a workday or not.
Dynamics NAV Developer since 2005
First of all you need to setup the base calendar in which you will tell the working and non working days.
Then you can check the last working using CALCDATE with the express <-1D>
Zohaib Ahmed
Dynamics NAV ERP Technical Consultant.
please like / agree / verify my answer, if it was helpful for you. thanks.
NAV provides a virtual Date-Table:
https://msdn.microsoft.com/en-us/library/dd355175(v=nav.90).aspx
At first, select the Days only by filtering:
SETRANGE("Period Type", "Period Type"::Date);
Then filter the current month:
SETRANGE("Period Start", CALCDATE('<-CM>', TODAY), CALCDATE('<CM>', TODAY));
--> the filter should be 01012017..31012017 (I don't have a dev-client right now to verify the DateExpression )
and then for the Period No. which represents the days in the week:
SETRANGE("Period No.", 1..5); // Monday to Friday
Then execute a FINDLAST and you will have the last week day of a month which normally represents the last working day of a month.
If you want to go a step further with that implementation, you must check the setup of the Base Calendar in NAV (and which Base Calendar you want to use). The table structure of the Base Calendar is similar to the virtual Date-table, but as a benefit it contains the field "Nonworking". The field could be used to identify public holidays.
Cheers,
Hannes