Excel教程:输入月份,就能自动生成当月日期?这些excel公式太好用了!
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">编按:</span></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">哈喽,<span style="color: black;">大众</span>好!<span style="color: black;">怎样</span>快速在一组时间数据中分别提取出年月日、时分秒数据?<span style="color: black;">怎样</span>快速计算某日期是年内第几周、星期几,以及日期之间间隔的天数、月数、年数、小时数、分钟数?<span style="color: black;">怎样</span>快速补全指定月份日期,合并日期和时间?今天老菜鸟针对<span style="color: black;">以上</span>在<span style="color: black;">平常</span>工作中经常会遇到的问题,总结了20个常用的关于日期和时间的公式,赶紧来<span style="color: black;">瞧瞧</span>吧!</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://mmbiz.qpic.cn/mmbiz_jpg/k6kCsib3eJMzppDibMWvVXMhVnyJDCD2kmq37g0ahJqRBhF6DKU75RZ9o21HobDYwzx1oxlto9MDnfdJOHkPtmpg/640?wx_fmt=jpeg&tp=webp&wxfrom=5&wx_lazy=1&wx_co=1" style="width: 50%; margin-bottom: 20px;"></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://mmbiz.qpic.cn/mmbiz_jpg/k6kCsib3eJMxZAP902kqL7wRke0cKLHSLvWnPKAIwSu2dh8u4EntIc9l0gdnXyj4xDjxb8icYsibLQYzZic32LTY2g/640?wx_fmt=jpeg&tp=webp&wxfrom=5&wx_lazy=1&wx_co=1" style="width: 50%; margin-bottom: 20px;"></p><span style="color: black;">在<span style="color: black;">实质</span>工作中,经常需要进行日期和时间的计算,如:工作日天数、入职天数、合同到期日期、员工生日提醒、计算加班时间........</span><span style="color: black;"><span style="color: black;">倘若</span>用人工计算会非常麻烦,而<span style="color: black;">运用</span>Excel函数公式则非常简单,今天给<span style="color: black;">大众</span>整理一期时间计算的公式<span style="color: black;">招数</span>大全,记得<span style="color: black;">保藏</span>起来慢慢看!(本教程<span style="color: black;">触及</span>的公式都比较<span style="color: black;">基本</span>,不做<span style="color: black;">太多</span>讲解,需要哪个公式直接套用<span style="color: black;">就可</span>。)</span>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">1</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">拆<span style="color: black;">归类</span>(共11个) </p><span style="color: black;">如下图所示,数据源为系统导出的格式,在这种数据源中,日期与时间是<span style="color: black;">同期</span>存在的,<span style="color: black;">针对</span>这种数据源<span style="color: black;">来讲</span>,<span style="color: black;">能够</span>从中获取对应的日期、时间,<span style="color: black;">从而</span><span style="color: black;">得到</span>年、月、日、时、分、秒以及年内周数,周内天数以及星期几等。</span><span style="color: black;"><img src="https://mmbiz.qpic.cn/mmbiz_png/k6kCsib3eJMzppDibMWvVXMhVnyJDCD2kmV7jtDbH8jaBibicuNBaTzroSvVujM1IiawqzTg7Ep2WTSO4mbO1oLHSng/640?wx_fmt=png&tp=webp&wxfrom=5&wx_lazy=1&wx_co=1" style="width: 50%; margin-bottom: 20px;"></span><span style="color: black;"><strong style="color: blue;"><span style="color: black;">公式1:拆分日期</span></strong></span><span style="color: black;"><span style="color: black;">运用</span>公式=INT(A2)得到日期,并修改单元格格式。</span><span style="color: black;"><img src="https://mmbiz.qpic.cn/mmbiz_png/k6kCsib3eJMzppDibMWvVXMhVnyJDCD2kmaQKSoKEdeIua6RiauiaocO4rlFco9o0dsGsLcMvZaZcHDt5pO4t7xPuQ/640?wx_fmt=png&tp=webp&wxfrom=5&wx_lazy=1&wx_co=1" style="width: 50%; margin-bottom: 20px;"></span><span style="color: black;"><strong style="color: blue;"><span style="color: black;">公式2:拆分时间</span></strong></span><span style="color: black;"><span style="color: black;">运用</span>公式=MOD(A2,1)得到时间,并修改单元格格式。</span><span style="color: black;"><img src="https://mmbiz.qpic.cn/mmbiz_png/k6kCsib3eJMzppDibMWvVXMhVnyJDCD2kmSOAiaQcBPoNjny7e5RWU3Q84ibXLh1BpbXrJCgqM9LPNndS1ATJ8ZNtg/640?wx_fmt=png&tp=webp&wxfrom=5&wx_lazy=1&wx_co=1" style="width: 50%; margin-bottom: 20px;"></span><span style="color: black;"><strong style="color: blue;"><span style="color: black;">公式3-5:获取年月日</span></strong></span><span style="color: black;">提取年的公式:=YEAR(A2)</span><span style="color: black;">提取月的公式:=MONTH(A2)</span><span style="color: black;">提取日的公式:=DAY(A2)</span><span style="color: black;"><img src="https://mmbiz.qpic.cn/mmbiz_gif/k6kCsib3eJMzppDibMWvVXMhVnyJDCD2kmwl95eEoFdyVRynoumpSdQN3coI7xyDMB54DTibNaMu44MicGJvXLragw/640?wx_fmt=gif&tp=webp&wxfrom=5&wx_lazy=1" style="width: 50%; margin-bottom: 20px;"></span><span style="color: black;"><strong style="color: blue;"><span style="color: black;">公式6-8:获取时分秒</span></strong></span><span style="color: black;">提取时的公式:=HOUR(A2)</span><span style="color: black;">提取分的公式:=MINUTE(A2)</span><span style="color: black;">提取秒的公式:=SECOND(A2)</span><span style="color: black;"><img src="https://mmbiz.qpic.cn/mmbiz_gif/k6kCsib3eJMzppDibMWvVXMhVnyJDCD2km2zzv4e5UFYeQmTFvCFKZMahHvmxSNjzBEFDPOGdrYvJibcVp9aKh7Rw/640?wx_fmt=gif&tp=webp&wxfrom=5&wx_lazy=1" style="width: 50%; margin-bottom: 20px;"></span><span style="color: black;"><strong style="color: blue;"><span style="color: black;">公式9:年内第几周</span></strong></span><span style="color: black;">公式=WEEKNUM(A2)<span style="color: black;">能够</span>得到一个数字,该数字<span style="color: black;">暗示</span>日期在这一年的第几周。</span><span style="color: black;"><img src="https://mmbiz.qpic.cn/mmbiz_png/k6kCsib3eJMzppDibMWvVXMhVnyJDCD2km5Bw9zua5H5AN13UyhHVdFJ0hOSG936MQg8Vzp8ruLYqYl2HAcpcl4g/640?wx_fmt=png&tp=webp&wxfrom=5&wx_lazy=1&wx_co=1" style="width: 50%; margin-bottom: 20px;"></span><span style="color: black;">WEEKNUM的应用场景:在某些场合,可能需要按周来进行<span style="color: black;">营销</span>分析,而<span style="color: black;">倘若</span>数据中<span style="color: black;">仅有</span>日期,此时就<span style="color: black;">能够</span>用WEEKNUM函数来辅助,再用透视表得到每周的汇总数据,如下图所示。</span><span style="color: black;"><img src="https://mmbiz.qpic.cn/mmbiz_png/k6kCsib3eJMzppDibMWvVXMhVnyJDCD2kmh3rsdY9UsXnvXRgbPLnVmKSotgZgiamiaMasJLAoagO3ddmFrG7q5yww/640?wx_fmt=png&tp=webp&wxfrom=5&wx_lazy=1&wx_co=1" style="width: 50%; margin-bottom: 20px;"></span><span style="color: black;"><strong style="color: blue;"><span style="color: black;">公式10-11:周内第几天和星期几</span></strong></span><span style="color: black;">先来看星期几的公式:=TEXT(A2,"aaaa")</span><span style="color: black;"><img src="https://mmbiz.qpic.cn/mmbiz_png/k6kCsib3eJMzppDibMWvVXMhVnyJDCD2kmNH77ScsbGTZezQ9AwN6PAjUxgo6YHfZ49iaiceSjOwwRbkEgoibLAHosw/640?wx_fmt=png&tp=webp&wxfrom=5&wx_lazy=1&wx_co=1" style="width: 50%; margin-bottom: 20px;"></span><span style="color: black;">"aaaa"是TEXT函数中的星期代码,关于TEXT函数之前有<span style="color: black;">非常多</span>教程,不<span style="color: black;">熟练</span>的小伙伴<span style="color: black;">能够</span>查看<span style="color: black;">文案</span>《<a style="color: black;">能做<span style="color: black;">要求</span>判断的文本函数,你见过吗?</a></span><span style="color: black;">》,<span style="color: black;">这儿</span>就不赘述了。</span><span style="color: black;">需要说明的是星期几和周内第几天之间的区别。</span><span style="color: black;"><span style="color: black;">一般</span><span style="color: black;">能够</span><span style="color: black;">运用</span>公式=WEEKDAY(A2,2)得到数字所<span style="color: black;">暗示</span>的星期几,如图所示。</span><span style="color: black;"><img src="https://mmbiz.qpic.cn/mmbiz_png/k6kCsib3eJMzppDibMWvVXMhVnyJDCD2kmom5fkpmCtN6yPicngyHt5FkQoubKUriat22gVYT2xygZeOatR4IufIww/640?wx_fmt=png&tp=webp&wxfrom=5&wx_lazy=1&wx_co=1" style="width: 50%; margin-bottom: 20px;"></span><span style="color: black;">然而这个公式的本质却并不是计算星期几,第二参数2<span style="color: black;">暗示</span>用星期一<span style="color: black;">做为</span><span style="color: black;">1星期</span>的<span style="color: black;">第1</span>天,<span style="color: black;">根据</span>这个规则来确定日期是本周的第几天。</span><span style="color: black;">WEEKDAY的应用场景:<span style="color: black;">平常</span>于对考勤统计中周末的判定,<span style="color: black;">重点</span>是星期六和星期天,公式=WEEKDAY(A2,2)>5<span style="color: black;">能够</span>直接得到判定结果,<span style="color: black;">从而</span><span style="color: black;">做为</span><span style="color: black;">详细</span>统计的<span style="color: black;">要求</span><span style="color: black;">运用</span>,<span style="color: black;">亦</span><span style="color: black;">能够</span><span style="color: black;">做为</span><span style="color: black;">要求</span>格式设置中的<span style="color: black;">要求</span><span style="color: black;">运用</span>。</span><span style="color: black;"><img src="https://mmbiz.qpic.cn/mmbiz_png/k6kCsib3eJMzppDibMWvVXMhVnyJDCD2km9CwqH7JBGmGTBsDjPHicrjhibrdLC2ibC6h7pD4wD8tgKRWbmUl1zap6w/640?wx_fmt=png&tp=webp&wxfrom=5&wx_lazy=1&wx_co=1" style="width: 50%; margin-bottom: 20px;"></span>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">2</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">合并类(共2个) </p><span style="color: black;"><strong style="color: blue;"><span style="color: black;">公式12:日期与时间合并</span></strong></span><span style="color: black;">这个很简单,两个单元格相加后再设置单元格格式就行了。</span><span style="color: black;">自定义格式的代码为yyyy/m/d h:mm:ss</span><span style="color: black;"><img src="https://mmbiz.qpic.cn/mmbiz_png/k6kCsib3eJMzppDibMWvVXMhVnyJDCD2kmsd5J0aEDuI6BQErzoGJicBTeNRnIx75RwtzPKwMLBNB60e4ODdDm3Vw/640?wx_fmt=png&tp=webp&wxfrom=5&wx_lazy=1&wx_co=1" style="width: 50%; margin-bottom: 20px;"></span><span style="color: black;"><strong style="color: blue;"><span style="color: black;">公式13:指定月份补全日期</span></strong></span><span style="color: black;">这种问题<span style="color: black;">平常</span>于考勤表中,指定月份就能得到该月的日期列表。</span><span style="color: black;">这类问题<span style="color: black;">一般</span><span style="color: black;">运用</span>DATE函数来补全日期,例如公式=DATE(2020,$A$2,COLUMN(A1))<span style="color: black;">能够</span>实现下图所示的效果。</span><span style="color: black;"><img src="https://mmbiz.qpic.cn/mmbiz_gif/k6kCsib3eJMzppDibMWvVXMhVnyJDCD2km8DZDbWQhjRibkeyhqk4Mxg8LmJBiaSb1JMp7uDlDw0bAgLSiasfqKmIUA/640?wx_fmt=gif&tp=webp&wxfrom=5&wx_lazy=1" style="width: 50%; margin-bottom: 20px;"></span>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">3</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">时间差和日期差(共5个) </p><span style="color: black;"><strong style="color: blue;"><span style="color: black;">公式14-15:计算时间间隔小时数、分钟数</span></strong></span><span style="color: black;">要计算两个时间之间的间隔小时,<span style="color: black;">能够</span><span style="color: black;">运用</span>公式:=(B2-A2)*24</span><span style="color: black;"><img src="https://mmbiz.qpic.cn/mmbiz_png/k6kCsib3eJMzppDibMWvVXMhVnyJDCD2km8u0z7xcnunJLOxFLlKiaqEejRZrBKcCSprbJe9dibibATqOV5YtahPiaTA/640?wx_fmt=png&tp=webp&wxfrom=5&wx_lazy=1&wx_co=1" style="width: 50%; margin-bottom: 20px;"></span><span style="color: black;">要计算两个时间之间的间隔分钟,<span style="color: black;">能够</span><span style="color: black;">运用</span>公式:=(B2-A2)*1440</span><span style="color: black;"><img src="https://mmbiz.qpic.cn/mmbiz_png/k6kCsib3eJMzppDibMWvVXMhVnyJDCD2kmlaw7K0qibiaAlgRgXvricn4Y7iaD69U2gzKGpCPEjx7AyniaAXcrlroQQog/640?wx_fmt=png&tp=webp&wxfrom=5&wx_lazy=1&wx_co=1" style="width: 50%; margin-bottom: 20px;"></span><span style="color: black;"><strong style="color: blue;"><span style="color: black;">公式16-18:计算两个日期之间的天数、月数和年数</span></strong></span><span style="color: black;">间隔天数:=B9-A9</span><span style="color: black;">间隔月数:=DATEDIF(A9,B9,"M")</span><span style="color: black;">间隔年数:=DATEDIF(A9,B9,"Y")</span><span style="color: black;"><img src="https://mmbiz.qpic.cn/mmbiz_png/k6kCsib3eJMzppDibMWvVXMhVnyJDCD2kmW50RL5Zsy3fqoIghA2hdz5m0Ticg7UycFCAlUytZcA2prM5a52yS2ibQ/640?wx_fmt=png&tp=webp&wxfrom=5&wx_lazy=1&wx_co=1" style="width: 50%; margin-bottom: 20px;"></span><span style="color: black;">间隔天数<span style="color: black;">能够</span>用两个日期直接相减,间隔月数和间隔年数<span style="color: black;">能够</span>用DATEDIF函数得到,不<span style="color: black;">熟练</span>这个函数的小伙伴<span style="color: black;">能够</span>查看这篇<span style="color: black;">文案</span>《<a style="color: black;">用上DATEDIF,您永<span style="color: black;">再也不</span>缺席<span style="color: black;">哪些</span>重要的日子!</a>》。</span>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">4</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">格式转换类(共2个) </p><span style="color: black;">格式转换<span style="color: black;">指的是</span>8位数字和日期之间的互换,常用于各类系统数据导出或导入时。</span><span style="color: black;"><strong style="color: blue;"><span style="color: black;">公式19:8位数字转换为日期</span></strong></span><span style="color: black;">=--TEXT(A16,"0-00-00")</span><span style="color: black;"><img src="data:image/svg+xml,%3C%3Fxml version=1.0 encoding=UTF-8%3F%3E%3Csvg width=1px height=1px viewBox=0 0 1 1 version=1.1 xmlns=http://www.w3.org/2000/svg xmlns:xlink=http://www.w3.org/1999/xlink%3E%3Ctitle%3E%3C/title%3E%3Cg stroke=none stroke-width=1 fill=none fill-rule=evenodd fill-opacity=0%3E%3Cg transform=translate(-249.000000, -126.000000) fill=%23FFFFFF%3E%3Crect x=249 y=126 width=1 height=1%3E%3C/rect%3E%3C/g%3E%3C/g%3E%3C/svg%3E" style="width: 50%; margin-bottom: 20px;"></span><span style="color: black;">说明:TEXT前的--是为了将文本变成数值,<span style="color: black;">倘若</span>不加--的话,得到的只是类似日期的一种文本结果。</span><span style="color: black;"><strong style="color: blue;"><span style="color: black;">公式20:日期转换为8位数字</span></strong></span><span style="color: black;">=TEXT(A23,"yyyymmdd")</span><span style="color: black;"><img src="data:image/svg+xml,%3C%3Fxml version=1.0 encoding=UTF-8%3F%3E%3Csvg width=1px height=1px viewBox=0 0 1 1 version=1.1 xmlns=http://www.w3.org/2000/svg xmlns:xlink=http://www.w3.org/1999/xlink%3E%3Ctitle%3E%3C/title%3E%3Cg stroke=none stroke-width=1 fill=none fill-rule=evenodd fill-opacity=0%3E%3Cg transform=translate(-249.000000, -126.000000) fill=%23FFFFFF%3E%3Crect x=249 y=126 width=1 height=1%3E%3C/rect%3E%3C/g%3E%3C/g%3E%3C/svg%3E" style="width: 50%; margin-bottom: 20px;"></span><span style="color: black;">说明:y、m、d指日期中的年月日,yyyy还可简写为e,关于这些内容,在text函数的教程中都有<span style="color: black;">仔细</span>解释。</span><span style="color: black;">小结:本文总结了最<span style="color: black;">基本</span>、常用的20个公式,关于日期时间类的问题其实还有<span style="color: black;">非常多</span>,<span style="color: black;">然则</span>万变不离其宗,<span style="color: black;">把握</span>基础公式之后,剩下的<span style="color: black;">便是</span><span style="color: black;">按照</span><span style="color: black;">详细</span>问题灵活应用了,<span style="color: black;">倘若</span>在日期时间方面你还有其他问题欢迎留言交流。</span><strong style="color: blue;">扫二维码</strong><strong style="color: blue;">免费学Excel等视频</strong>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="data:image/svg+xml,%3C%3Fxml version=1.0 encoding=UTF-8%3F%3E%3Csvg width=1px height=1px viewBox=0 0 1 1 version=1.1 xmlns=http://www.w3.org/2000/svg xmlns:xlink=http://www.w3.org/1999/xlink%3E%3Ctitle%3E%3C/title%3E%3Cg stroke=none stroke-width=1 fill=none fill-rule=evenodd fill-opacity=0%3E%3Cg transform=translate(-249.000000, -126.000000) fill=%23FFFFFF%3E%3Crect x=249 y=126 width=1 height=1%3E%3C/rect%3E%3C/g%3E%3C/g%3E%3C/svg%3E" style="width: 50%; margin-bottom: 20px;"></p><img src="data:image/svg+xml,%3C%3Fxml version=1.0 encoding=UTF-8%3F%3E%3Csvg width=1px height=1px viewBox=0 0 1 1 version=1.1 xmlns=http://www.w3.org/2000/svg xmlns:xlink=http://www.w3.org/1999/xlink%3E%3Ctitle%3E%3C/title%3E%3Cg stroke=none stroke-width=1 fill=none fill-rule=evenodd fill-opacity=0%3E%3Cg transform=translate(-249.000000, -126.000000) fill=%23FFFFFF%3E%3Crect x=249 y=126 width=1 height=1%3E%3C/rect%3E%3C/g%3E%3C/g%3E%3C/svg%3E" style="width: 50%; margin-bottom: 20px;">
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;">Excel教程<span style="color: black;">关联</span><span style="color: black;">举荐</span></strong></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><a style="color: black;"><span style="color: black;">Excel教程:各类职场人<span style="color: black;">怎样</span>用Excel制作目录?看了这么多种,还是最服你!</span></a></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><a style="color: black;"><span style="color: black;">Excel教程:用99个空格来提取单元格数据,你会吗?</span></a></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><a style="color: black;">Excel教程:你真的会</a>用Ctrl + E吗??</span></p><strong style="color: blue;"><span style="color: black;"><img src="data:image/svg+xml,%3C%3Fxml version=1.0 encoding=UTF-8%3F%3E%3Csvg width=1px height=1px viewBox=0 0 1 1 version=1.1 xmlns=http://www.w3.org/2000/svg xmlns:xlink=http://www.w3.org/1999/xlink%3E%3Ctitle%3E%3C/title%3E%3Cg stroke=none stroke-width=1 fill=none fill-rule=evenodd fill-opacity=0%3E%3Cg transform=translate(-249.000000, -126.000000) fill=%23FFFFFF%3E%3Crect x=249 y=126 width=1 height=1%3E%3C/rect%3E%3C/g%3E%3C/g%3E%3C/svg%3E" style="width: 50%; margin-bottom: 20px;"></span></strong>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">让工作提速百倍的「Excel极速贯通班」</span></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">↓ 点击<span style="color: black;"><strong style="color: blue;"><span style="color: black;">阅读原文</span></strong></span>,可直接购买。</span></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;"><span style="color: black;">倘若</span>对你有<span style="color: black;">帮忙</span>,点下“在看”呦</span><img src="data:image/svg+xml,%3C%3Fxml version=1.0 encoding=UTF-8%3F%3E%3Csvg width=1px height=1px viewBox=0 0 1 1 version=1.1 xmlns=http://www.w3.org/2000/svg xmlns:xlink=http://www.w3.org/1999/xlink%3E%3Ctitle%3E%3C/title%3E%3Cg stroke=none stroke-width=1 fill=none fill-rule=evenodd fill-opacity=0%3E%3Cg transform=translate(-249.000000, -126.000000) fill=%23FFFFFF%3E%3Crect x=249 y=126 width=1 height=1%3E%3C/rect%3E%3C/g%3E%3C/g%3E%3C/svg%3E" style="width: 50%; margin-bottom: 20px;"></span></p>
感谢你的精彩评论,为我的思绪打开了新的窗口。 这夸赞甜到心里,让我感觉温暖无比。 “BS”(鄙视的缩写)
页:
[1]