给定日期范围内哪些天是工作日
是否有内置函数可以告诉我哪几天是工作日?这就是我的意思,
如果我选择今天的日期(2011 年 6 月 14 日),它会给我今天打卡的所有检查号码。该交货时间包括周末。因此,如果我有一位客户在 10 号(星期五)开始一个项目并在今天完成;它显示大约花了五天,而不是三天。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我相信很久以前就有一个函数可以做到这一点,但我相信该函数已被删除。我相信您应该能够使用类似以下内容的方法来计算两个日期之间的工作日:
这会获取总天数差异并从总数中减去周六和周日。请注意,这不包括假期。为此,您需要将它们维护在您自己的用户函数库中并将它们包含在计算中。
希望这有帮助。
I believe there used to be a function to do this a long long time ago, but I believe that function has since been removed. I believe that you should be able to use something like the following which calculates the business days between two dates:
This gets the total days difference and subtracts the saturdays and sundays from the total. Note this does not include holidays. For that you'd need to maintain them in your own User Function Library and include them in the calculation.
Hope this helps.
这是我想出的解决方案。基本上,如果超过 7 天,我知道要减去多少天。如果不到 7 天,我仍然可以判断它是否跨越周末。 Crystal Reports 有一个函数 DayOfWeek,它返回当天的数字,即星期日 = 1、星期一 = 2 等。如果结束时间日期数字小于开始时间数字,我们就知道周末已经过去。我们可以减去 2。timeDiff
是开始日期 - 结束日期。
我的网站上有更深入的解释。链接是此处
This is the solution i came up with. Pretty much if it is anything over 7 days i know how many days to subtract. if it is under 7 days i can still figure out if it spanned the weekend. Crystal reports has a function DayOfWeek that returns a number for the day i.e. Sunday = 1, Monday = 2, etc. If the finish time day number is less than the start time number we know it passed the weekend. and we can subtract 2.
timeDiff is startdate - finishdate.
I have a more in depth explanation on my website. the link is here
这是一个怪物解决方案,也考虑了公共假期:
上面的代码是根据 KenHamady。
以下函数由前一个函数调用并返回所有公共假期:
上面的代码基于这篇文章中的自定义函数克雷格。
假期函数需要能够获取给定年份的复活节星期日的日期:
来自 美国海军天文台。
Here is a monster solution that also takes public holidays into account:
Code above modified from solution found at KenHamady.
The following function is called by the previous function and returns all public holidays:
Code above based on the custom function in this post by craig.
The holiday function need to be able to get the date for easter sunday for a given year:
Easter sunday calculation formula from United States Naval Observatory.