如何从随机日期获得下周四? [英] How do I get next Thursday from a random date?

查看:18
本文介绍了如何从随机日期获得下周四?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要做的是让你有一个随机日期列表,它永远不会相同,所以它必须是一个通用公式,但是你得到任何日期,一年中的任何日期,然后每个星期四是新的一周开始.对于每个日期,您将日期设置为大于上一个且小于星期四的星期四.

What I want to do is so you have a list of random dates, it will never be the same so it has to be a universal formula, but you get any date, any date of the year and then every Thursday is the Starting of a new week. For each date you set the date equal to the Thursday that it is greater than the previous and less than the Thursday.

由于我含糊不清,请举例说明,假设您得到 2012 年 6 月 24 日.6 月 24 日大于 2012 年 6 月 21 日(即上一个星期四),小于 2012 年 6 月 28 日,即下一个周四.这意味着它应该在其旁边的列中生成 2012 年 6 月 28 日的值.

Example to clarify since I am being vague, say you get June 24th, 2012. June 24th is greater than June 21st, 2012 (which is the previous Thursday) and it is less than June 28th, 2012, which is the next Thursday. This means it should generate the value June 28th, 2012 in the column next to it.

这有意义吗?根据您获得的任何日期值,您计算它应该生成哪个星期四日期?有什么办法可以在excel中做到这一点?

Is that making any sense? Based on any date value you get, you calculate which Thursday date it should generate? Any way to do this in excel?

推荐答案

这个公式将为您提供 A1 日期之后的星期四

This formula will give you the Thursday following a date in A1

=A1+7-WEEKDAY(A1+2)

如果 A1 是星期四,则返回该日期,如果 A1 是星期四,则应为 A1+7,则更改为该版本

If A1 is a Thursday it returns that date, if it should be A1+7 if A1 is Thursday then change to this version

=A1+8-WEEKDAY(A1+3)

这篇关于如何从随机日期获得下周四?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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