[英]generate list of A predetermined amount of dates in only specified days of week and excluding specific list of dates using google script
I want to make a list of meetings/lessons (in google sheets) which recurring at sundays and wednesdays only (for example), except holidays and/ot other predefined dates. 我想列出仅在星期日和星期三(例如)重复的会议/课程列表(在Google表格中 ),节假日和/或其他预定义的日期除外。 the list of "holidays" may be growing, so the list must skip this days and always stay on 69 meetings/lessons enter image description here the simple function in cell A3 and so on like:
“假期”的列表可能正在增长,因此该列表必须跳过这一天,并且始终停留在69个会议/课程上, 在此处输入图像描述,在单元格A3中使用简单功能,诸如此类:
=IF(WEEKDAY(A2)=1,A2+3,A2+4)
won't work properly because it doesn't know skip list of holidays. 无法正常运行,因为它不知道跳过假期清单。 and
和
=WORKDAY.INTL()
won't work because can't apply to only sunday,wednesday. 无法正常运作,因为不能只适用于星期日,星期三。 so I must create a script that uses same rules as =WORKDAY.INTL() but teach it to use only specific weekdays.
因此,我必须创建一个使用与= WORKDAY.INTL()相同的规则的脚本,但要教其仅使用特定的工作日。
any help be appreciated. 任何帮助,不胜感激。 thanks in advance.
提前致谢。
Assume, we have values in cells: 假设,我们在单元格中有值:
B2
= 69 (or any number) B2
= 69(或任何数字) A2
= 3/9/2016 (first date) A2
= 3/9/2016(第一次约会) C2:C
= list of dates to skip C2:C
=要跳过的日期列表 Paste this formula into cell A3
: 将此公式粘贴到单元格
A3
:
=QUERY(ARRAYFORMULA((if(ISEVEN(row(OFFSET(A1,,,B2-1+counta(C2:C)))),row(OFFSET(A1,,,B2-1+counta(C2:C)))/2*3+row(OFFSET(A1,,,B2-1+counta(C2:C)))/2*4,(row(OFFSET(A1,,,B2-1+counta(C2:C)))-1)/2*3+(row(OFFSET(A1,,,B2-1+counta(C2:C)))-1)/2*4+4)+A2)*(--not(regexmatch(text(if(ISEVEN(row(OFFSET(A1,,,B2-1+counta(C2:C)))),row(OFFSET(A1,,,B2-1+counta(C2:C)))/2*3+row(OFFSET(A1,,,B2-1+counta(C2:C)))/2*4,(row(OFFSET(A1,,,B2-1+counta(C2:C)))-1)/2*3+(row(OFFSET(A1,,,B2-1+counta(C2:C)))-1)/2*4+4)+A2,"dd/mm/yyyy ddd"), "(?i)" & JOIN("|",filter(C2:C,C2:C>0)))))),"select Col1 where Col1 > date'1900-01-01'",0)
The formula will expand automatically and show the result. 公式将自动展开并显示结果。
Numbers 3 and 4 in the formula may be changed to select another days. 公式中的数字3和4可能会更改为选择其他日期。
Date format "dd/mm/yyyy ddd"
in formula is to be changed to your format. 公式中的日期格式
"dd/mm/yyyy ddd"
将更改为您的格式。
Example 例
Please, try it yourself 请自己尝试
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.