excel日期相减去除周末

With Excel Data Validation, you can add rules to a data entry sheet, and control what people put in the cells. In today's example, we'll set up a cell that only allows you to enter a weekend date. Just remember that Data Validation isn't foolproof, and people can find ways around your rules.

使用Excel数据验证,您可以将规则添加到数据输入表中,并控制人们在单元格中放置的内容。 在今天的示例中,我们将设置一个仅允许您输入周末日期的单元格。 请记住,数据验证并非万无一失,人们可以找到绕过您规则的方法。

周末约会挑战 (Weekend Date Challenge)

Here's what we want in our data entry sheet. People can enter a date in cell B2, but we want them to enter weekend dates only.

这就是我们在数据输入表中想要的。 人们可以在单元格B2中输入日期,但是我们希望他们仅输入周末日期。

If they put a Monday to Friday date in cell B2, a warning message should appear, and block that date from being entered.

如果他们在单元格B2中输入了星期一到星期五的日期,则会出现一条警告消息,并阻止该日期的输入。

数据验证下拉列表 (Data Validation Drop Downs)

One way to make sure that people make valid entries in a cell, is to set up a drop down list, and only allow those items. That's handy for a short list of items, such as employee names, or product categories.

确保人们在单元格中进行有效输入的一种方法是设置一个下拉列表 ,并仅允许这些项目。 对于简短的项目列表(例如员工姓名或产品类别),这很方便。

A drop down list wouldn't be a good solution in this case though. We'd need to make a list of all possible weekend dates, and who has time for that?

但是,在这种情况下,下拉列表并不是一个好的解决方案。 我们需要列出所有可能的周末约会清单,谁来安排时间?

日期数据验证 (Data Validation for Dates)

Another Data Validation option is its set of built-in  Date Rules.

另一个数据验证选项是其内置的日期规则集 。

You can use those rules if you want to restrict dates  to a specific date range. Choose an operator from the drop down list, such as Greater Than, or Not Equal To.

如果要将日期限制为特定日期范围,则可以使用这些规则。 从下拉列表中选择一个运算符,例如“大于”或“不等于”。

Then, fill in the date boxes that appear for the selected option. For example, choose Between, and set a start date and end date for the valid date range.

然后,填写为所选选项显示的日期框。 例如,选择“之间”,然后为有效日期范围设置开始日期和结束日期。

数据验证自定义规则 (Data Validation Custom Rule)

Unfortunately, none of those built-in date options let you limit dates to specific days of the week.

不幸的是,这些内置日期选项均无法将日期限制为一周中的特定日期。

To do that, you can set up a Data Validation Custom Rule.

为此,您可以设置数据验证自定义规则。

Next, you'll need to enter a formula for the custom rules, to tell Excel that only weekend dates are allowed.

接下来,您需要输入自定义规则的公式,以告诉Excel仅允许周末日期。

确定工作日 (Identify the Weekday)

I like to test formulas on the worksheet, before adding them to the Data Validation custom rule settings.

我喜欢先在工作表上测试公式,然后再将其添加到“数据验证”自定义规则设置中。

In the screen shot below, the date in cell B2 is Thursday, December 13th, formatted to show the weekday name.

在下面的屏幕快照中,单元格B2中的日期是12月13日星期四,其格式设置为显示工作日名称。

There are 7 days in a week, and with the Excel WEEKDAY function, we can get a number for the weekday that a date falls on.

一周中有7天,并且使用Excel WEEKDAY函数 ,我们可以获取日期所在的工作日的数字。

Here is my test formula, in cell B4:

这是我在B4单元格中的测试公式:

=WEEKDAY(B2)

=星期(B2)

The result is 5 – the weekday number for Thursday.

结果为5 –星期四的工作日数。

星期几编号 (WEEKDAY Numbering)

My formula uses the default setting for WEEKDAY, which numbers the days from Sunday (1) to Saturday (7).

我的公式使用WEEKDAY的默认设置,该设置从周日(1)到周六(7)进行编号。

So, we could make a rule that only allows dates with a weekday number of 1 (Sunday) OR 7 (Saturday).

因此,我们可以制定一条规则,只允许工作日编号为1(星期日)或7(星期六)的日期。

=OR(WEEKDAY(B2)=1,WEEKDAY(B2)=7)

= OR(WEEKDAY(B2)= 1,WEEKDAY(B2)= 7)

The date is B2 is not a Sunday or Saturday, so the formula result is FALSE. That date would not be allowed.

日期为B2而不是星期日或星期六,因此公式结果为FALSE。 该日期将不被允许。

WEEKDAY功能选项 (WEEKDAY Function Options)

Instead of checking for 1 and 7, we could make a change to the WEEKDAY formula, so that we only have to do one check.

无需检查1和7,我们可以更改WEEKDAY公式,因此我们只需要进行一次检查。

There is an optional argument for WEEKDAY – return_type. If you omit that argument, the default (1) is used.

WEEKDAY有一个可选参数– return_type 。 如果省略该参数,则使用默认值(1)。

更改退货类型 (Change the Return Type)

If we use 2 as the return_type, the numbers start with Monday as 1. That puts Saturday and Sunday together at the end of the list, with numbers 6 and 7.

如果我们使用2作为return_type,则数字从星期一开始为1。这将星期六和星期日放在列表的末尾,分别是数字6和7。

That lets us create a simpler formula – we can check for numbers greater than 5 (Friday).

这使我们可以创建一个更简单的公式–我们可以检查大于5(星期五)的数字。

=WEEKDAY(B2,2)>5

=星期(B2,2)> 5

With the Thursday date in B2, the formula returns FALSE – it is not a valid weekend date.

对于B2中的星期四日期,该公式将返回FALSE –这不是有效的周末日期。

If I change the date in B2 to December 15th (a Saturday), the result is TRUE. That is a weekend date, and would be allowed.

如果我将B2中的日期更改为12月15日(星期六),则结果为TRUE。 那是周末,可以允许。

创建数据验证自定义规则 (Create the Data Validation Custom Rule)

After you've tested the formula on the worksheet, and it works correctly, set up the Data Validation Custom Rule.

在工作表上测试了公式之后,该公式可以正常工作,然后设置“数据验证自定义规则”。

  • Select cell B2, and on the Data tab, click Data Validation选择单元格B2,然后在“数据”选项卡上,单击“数据验证”
  • From the Allow drop down, choose Custom从“允许”下拉列表中,选择“自定义”
  • In the Formula box, type the formula that you tested:  =WEEKDAY(B2,2)>5

    在“公式”框中,键入您测试的公式: = WEEKDAY(B2,2)> 5

  • To show an error message, click the Error Alerts tab and set up an Error message

    要显示错误消息,请单击“错误警报”选项卡并设置错误消息

  • Click OK, to apply the custom rule单击确定,以应用自定义规则

Test the rule in cell B2, by entering a few weekend dates, and non-weekend dates.

通过输入一些周末日期和非周末日期来测试单元格B2中的规则。

更多自定义规则 (More Custom Rules)

Go to my Contextures website, to see more Custom Rules for Data Validation. There is a sample file that you can download, with those examples.

转到我的Contextures网站,查看更多有关数据验证的自定义规则 。 您可以下载带有这些示例的样本文件。

使用Excel数据验证来防止无效日期 (Prevent Invalid Dates With Excel Data Validation)

Here's another example of using data validation to control which dates can be entered in Excel. In this video, 3 different methods are used to validate dates.

这是使用数据验证来控制可以在Excel中输入哪些日期的另一个示例。 在此视频中,使用了3种不同的方法来验证日期。

  • Specify a starting date and an ending date. (Date option)指定开始日期和结束日期。 (日期选项)
  • Show a drop down list of valid dates (List option)显示有效日期的下拉列表(列表选项)
  • Create a rule in a custom formula (Custom option)在自定义公式中创建规则(“自定义”选项)

Written instructions, and the sample file, are on the Data Validation for Dates page, on my Contextures site.

书面说明和示例文件位于Contextures网站上的“ 日期数据验证”页面上。

演示地址

翻译自: https://contexturesblog.com/archives/2018/12/13/allow-weekend-dates-only-in-excel/

excel日期相减去除周末


http://www.taodudu.cc/news/show-2830796.html

相关文章:

  • excel日期相减去除周末_在Excel中突出显示周末日期
  • Excel中时间相减的实例教程
  • Excel 时间格式相减
  • Excel使用之时间相加减(精确到毫秒)
  • 图格 Pro for mac(图片拼图切图大师)
  • 喜欢游戏学计算机,我喜欢电脑游戏小学作文
  • 公众号怎么设置滑动文字_这种微信公众号里面滑动是怎么操作的?
  • php文字加边框,图片加特效文字 图片添加各种边框的文字效果 如果有多种边框模板就更好了...
  • html用九张图片做出九宫图,九宫切图软件 如何快速把照片做成九宫格切图
  • html手机9张图片显示,怎么把一张图片分成9张(手机美图秀秀九宫格在哪)
  • c语言游戏(C语言游戏装备)
  • 背篼酥课堂第八课--APP开发--app图形化编程
  • java设计九宫格拼图软件哪个好用_抖音超火的朋友圈九宫格用什么软件做的? 抖音九宫格图片制作教程...
  • 用纯css实现一个图片拼接九宫格
  • 拼出爱心图案的c语言,抖音爱心图片拼图9格照片怎么弄 高格调拼图已被霸屏
  • 不可还原的拼图
  • 拼图游戏Canvas版
  • A*算法实现9宫格拼图游戏最优解
  • 九格智能拼图算法
  • 九格拼图游戏
  • 将小写金额转换成中文大写
  • Twitter注册如何做到ip防关联
  • 用R对Twitter用户的编程语言语义分析
  • twitter无手机号检查_如何检查Twitter帐户是否为Bot
  • twitter账户受限_如何为您的企业设置Twitter帐户
  • 推特开发者账号的申请流程
  • Twitter爬虫Python库Tweepy 附中英文官方文档
  • 颜色转换公式大全及转换表格(31种)
  • bash install.sh ********错误
  • 整数DCT实现原理

excel日期相减去除周末_仅在Excel中允许周末日期相关推荐

  1. excel日期相减去除周末_在Excel中突出显示周末日期

    excel日期相减去除周末 Yes, the weekend is over, but another one is just five days away! To make it easier to ...

  2. mysql时间相减得到天数保留两位_mysql 中两个日期相减获得 天 小时 分钟 或者 小时:分钟的格式...

    /**有一个需求,要求获得两个日期想减的天数,小时数,分钟数.通过查找资料,于是乎我写出了如下代码,来获得两个字段.*/ IFNULL(CONCAT( IF(aib.`forecast_reply_t ...

  3. 日期相减计算年_函数 | Excel有个“秘密”函数,计算年龄工龄特方便

    工作中经常会遇到涉及日期间隔的计算问题,比如计算两个日期之间的天数.月数.年数,这时需要用到Excel中一个秘密函数. 说到"秘密",是因为你在微软Excel提供的的函数列表里是找 ...

  4. 日期相减计算年_Excel教程:excel日期问题的小妙招

    提示:小程序可以高清看本公众号视频教程 苹果iOS用户请微信扫码学习 1.怎么快速输入当前日期? 函数: 输入公式:=TODAY() TODAY函数:返回日期格式的当前日期. 搜狗输入法: 在搜狗输入 ...

  5. date js 减去_如何在JavaScript中从该日期减去一个星期?

    您需要从当前日期减去一个星期,即7天.以下是语法-var anyVariableName=new Date(yourCurrentDate.setDate(yourCurrentDate.getDat ...

  6. excel函数:汉字转全拼_星期五的Excel函数:带过滤器的小计和总和

    excel函数:汉字转全拼 Last week, we used the Excel SUBTOTAL function to sum items in a filtered list, while ...

  7. wps表格日期计算天数_如何计算Google表格中两个日期之间的天数

    wps表格日期计算天数 If you want to count the number of days between two dates, you can use the DAYS, DATEDIF ...

  8. wps斜杠日期格式_在WPS表格中轻松统一日期格式

    平常办公中经常需要收集汇总下级各部门上报的数据表格.由于各部门输入人员并没有按统一标准格式输入日期,汇总数据之后往往会发现汇总数据中的日期有很多种格式.除了2009-2-3.1978年5月6日等标准格 ...

  9. access日期如何增加年数_如何为Access数据库表添加日期或时间戳

    为了应用方便,您可能需要给数据库的每条记录都添加日期/时间戳,以便确定各个记录添加到数据库的时间.在Access数据库应用中,使用Now()函数能够轻松完成这个任务.本文将一步一步为您介绍整个添加过程 ...

最新文章

  1. python查看微信撤回消息_想查看微信好友撤回的消息?Python帮你搞定
  2. .NET泛型解析(下)
  3. 智能驾驶L2的黄金时代,打磨地图是关键
  4. 大数据和高并发的解决方案汇总
  5. 转:VirtualBox虚拟机网络连接设置的四种方式
  6. Flink SQL 的 9 个示例
  7. 华 为 路 由 器 命 令 大 全
  8. Redis服务器的启动过程分析
  9. Kafka:ZK+Kafka+Spark Streaming集群环境搭建(十九)ES6.2.2 安装Ik中文分词器
  10. 怎么获取求生之路服务器信息失败,新人服务器出现问题 求助求助!!!!!...
  11. Mindomo Desktop for Mac(思维导图)中文版
  12. Go编程语言能干什么
  13. 三步建立自己的电影网站 1 (安装MacCMS10)
  14. Google BigQuery带你走进大数据
  15. HDU 1069 Monkey and Banana
  16. Cocos实战案例:高手解析《捕鱼达人3》怎样玩3D
  17. iphone二手机在哪里回收比较好(哪里回收的价格最高)
  18. 一则软件需求有关的漫画
  19. 这届618:掀起直播盛世
  20. parted 4T磁盘

热门文章

  1. Google 后 Hadoop 时代的新 “三驾马车” -- Caffeine(搜索)、Pregel(图计算)、Dremel(查询)
  2. 前缀学习完结篇 第三课上
  3. 如何查看IE浏览器版本?在线检测IE版本号
  4. 笔记本无线上网设置教程(图文)
  5. 不只是技术!成为IT经理必备的十大软技能
  6. Word 2010 中的 VBA 入门
  7. Vue-纯前端导出word文档 Can‘t find end of central directory:is this a zip file?
  8. dom4j的一些总结
  9. 我的世界java播放背景音乐_我的世界BOSS音乐mod
  10. vue项目storage本地存储