日期应自动更改为工作日。 [英] Dates should automatically change to weekdays.

查看:85
本文介绍了日期应自动更改为工作日。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一份报告,其中一个字段是计划出发日期。该报告还有一个截止日期的附加字段。截止日期是出发日期前两天,但应仅包括工作日。


= [计划出发日期] -2


但是,如果计划的出发日期是星期一或星期二,则截止日期是星期六或星期日,应该是星期五。


怎么做我的日期自动更改为星期五?

I have a report with one of the fields being a planned departure date. The report has an additional field for a cut-off date. The cut-of date is two days prior to the departure date, but should only include weekdays.

=[Planned Departure Date]-2

However, if the planned departure date is on a Monday or Tuesday, then the cut-off date is on a Saturday or Sunday and it should be on the Friday.

How do I have the date automatically change to the Friday?

推荐答案

您可以使用Weekday()函数来确定它是否是周末,然后相应地执行计算。
You could use the Weekday() function to known if it is a weekend and then perform your calculation accordingly.
展开 | 选择 | Wrap | 行号


嗨Charl,

使用iif会比切换更好
Hi Charl,
use iif will do this better than switch
展开 | 选择 | Wrap | 行号


@hvsummer工作日函数永远不会返回8或9,只返回1到7.此外,Switch函数是实际上比嵌套的IIF()更优选,因为如果功能需要改变的可读性。我不确定是否评估了Switch函数的所有部分,但我知道IIF函数的两边都被评估,因此嵌套IIF()s没有性能提升。
@hvsummer The weekday function will never return 8 or 9, only 1 through 7. Also, the Switch function is actually more preferable than nested IIF()s because of the readability if the functionality would ever need changed. I''m not sure if all parts of the Switch function are evaluated, but I do know that both sides of the IIF function are evaluated, so there is no performance gain from nesting IIF()s.


这篇关于日期应自动更改为工作日。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆