Auto-populate every second day between two given dates

♀尐吖头ヾ 提交于 2019-12-25 01:26:51

问题


I'm currently using the formula in this article to auto-populate a column of dates between to given dates:

=ArrayFormula(TO_DATE(row(indirect("A"&A2):indirect("A"&B2))))

How can I tweak the formula to give every second date? Column D in the article would then say:

  • 01/04/2018
  • 03/04/2018
  • 05/04/2018
  • 07/04/2018 ...and so on.

回答1:


It seems like the formula skips a day if the start date is an odd date. Can this be corrected?

=ARRAYFORMULA(FILTER(TO_DATE(ROW(INDIRECT("A"&A2):INDIRECT("B"&B2))),
 MOD(ROW(INDIRECT("A1:A"&COUNTA(TO_DATE(ROW(INDIRECT("A"&A2):INDIRECT("B"&B2)))))), 2)))




回答2:


=ARRAYFORMULA(FILTER(TO_DATE(ROW(INDIRECT("A"&A2):INDIRECT("B"&B2))),
                 MOD(TO_DATE(ROW(INDIRECT("A"&A2):INDIRECT("B"&B2))), 2)))




回答3:


=ARRAYFORMULA(FILTER(TO_DATE(ROW(INDIRECT("A"&A2):INDIRECT("B"&B2))),
               ISODD(TO_DATE(ROW(INDIRECT("A"&A2):INDIRECT("B"&B2))))))

=ARRAYFORMULA(FILTER(TO_DATE(ROW(INDIRECT("A"&A2):INDIRECT("B"&B2))),
              ISEVEN(TO_DATE(ROW(INDIRECT("A"&A2):INDIRECT("B"&B2))))))



来源:https://stackoverflow.com/questions/55541965/auto-populate-every-second-day-between-two-given-dates

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!