仅工作日和删除周末

时间:2019-04-01 14:48:08

标签: google-sheets google-sheets-formula

在我的A栏中,我有整个月的日期。现在,我要删除所有周末,仅保留工作日,即仅星期一至星期五。

enter image description here

2 个答案:

答案 0 :(得分:1)

=ARRAYFORMULA(FILTER(A2:A, TEXT(A2:A, "ddd")<>"sat",
                           TEXT(A2:A, "ddd")<>"sun"))

0

答案 1 :(得分:0)

一口气就是:

=ARRAYFORMULA(TEXT(FILTER(TO_DATE(ROW(
 INDIRECT("A"&DATE(2019, 1, 1)):
 INDIRECT("B"&EOMONTH(DATE(2019, 1, 1), 0)))), TEXT(TO_DATE(ROW(
 INDIRECT("A"&DATE(2019, 1, 1)):
 INDIRECT("B"&EOMONTH(DATE(2019, 1, 1), 0)))), "ddd")<>"sat", TEXT(TO_DATE(ROW(
 INDIRECT("A"&DATE(2019, 1, 1)):
 INDIRECT("B"&EOMONTH(DATE(2019, 1, 1), 0)))), "ddd")<>"sun"), "dd-mmm-yyyy"))

0

或更短:

=ARRAYFORMULA(TEXT(FILTER(TO_DATE(ROW(
 INDIRECT("A"&        DATE(2019, 1, 1)):
 INDIRECT("B"&EOMONTH(DATE(2019, 1, 1), 0)))), REGEXREPLACE(TEXT(TO_DATE(ROW(
 INDIRECT("A"&        DATE(2019, 1, 1)):
 INDIRECT("B"&EOMONTH(DATE(2019, 1, 1), 0)))), "ddd"),"Sat|Sun","♠")<>"♠"), "dd-mmm-yyyy"))