I run a report that calculates the difference in days between the sales invoice header shipment date and the sales invoice header posting date. I need the report to ignore weekends and calculate the difference between a Friday and the following Tuesday as 2 days and not 4 days.
Is there any method I can use?
Thanks in advance.
0
Comments
You get an integer representing the number of days when you subtract a date from another date. So if you did 12312007D - 01022007D you would get 363. If you divide this number by 7 then you get the number of weeks that have elapsed. 363 / 7 = 51.857, or 51+ weeks. 51 * 5 weekdays is 252 days.
There would need to be some boundary checking because in your case a Friday to Monday would only be 2 days, but would come out to less than 1 week and thus 0 days in the sample above. Hopefully it's a start for you.
My Blog - nav.education
http://www.mibuso.com/forum/viewtopic.php?t=2565
http://www.BiloBeauty.com
http://www.autismspeaks.org
My Blog - nav.education
If you need to take them into account its best to use the base calendar to count this days. You can step day by day through this calendar from shipping day to invoicing day, and count only those days that are working days.
Consultant-Developper
http://www.CreaChain.com
I remembered looking at this post and thought it was a good solution for you, I have tested it and it worked fine. \:D/
Calendar.RESET;
Calendar.SETRANGE("Period Type",Calendar."Period Type"::Date);
Calendar.SETRANGE("Period Start","Posting Date",TODAY);
Calendar.SETRANGE("Period No.",1,5);
MESSAGE('%1',Calendar.COUNT);
And I learned something today as well, one I will remember!
David
Mobile: +44(0)7854 842801
Email: david.cox@adeptris.com
Twitter: https://twitter.com/Adeptris
Website: http://www.adeptris.com
I'll try and use the suggestions in my report and let you know which one works for me.
I'm not a developer so it may take a while.
Thanks
lodger