excel 如果日期落在周末默认为上一个星期五 [英] excel if date falls on weekend default to previous friday

查看:35
本文介绍了excel 如果日期落在周末默认为上一个星期五的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在不同的列中有以下两个函数,我需要对这两个函数应用一个函数:

I have the following two functions in different columns and I need to apply a function to both :

=DATE(YEAR(E5);MONTH(E5);DAY(E5))

=TRUNC([@CAT]-TIME(10;0;0))

对于他们两个,如果日期在周末,我需要默认为星期五.如果日期日期在一周内,则需要保留工作日日期.

For both of them I need to default to a Friday if the date falls over the weekend. if date date is during the week it needs to keep the weekday date.

例如:2018/03/11 周日必须是 2018/03/09

e.g: Sunday 2018/03/11 needs to be 2018/03/09

例如:周一 2018/03/5 需要保持不变 2018/03/05

e.g: Monday 2018/03/5 needs to stay the same 2018/03/05

我曾尝试将 IF 语句与工作日 (1-7) 一起使用,但如果它是错误的,则从日期减去一两天(所以在星期四到星期二)

I have tried using an IF statement with a Weekday (1-7) but when its false it minus a day or two from the date (So on a Thursday it goes to Tuesday)

推荐答案

=WORKDAY(your_formula +1;-1)

会做你想做的事.

如果 your_formula 解析为周六或周日,并且我们添加一 (1) 天,然后减去一 (1) 个工作日,则结果将是之前的周五,因为周日或周一减去一个工作日 --> 周五.

If your_formula resolves to a Sat or Sun, and we add one(1) day, then subtract one (1) workday, the preceding Fri will be the result, Since either Sun or Mon minus one workday --> Friday.

这篇关于excel 如果日期落在周末默认为上一个星期五的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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