Given an ISO 8601 week number, get date of first day of that week in LibreOffice Calc spreadsheet

被刻印的时光 ゝ 提交于 2020-01-24 08:47:08

问题


LibreOffice Calc spreadsheet offers a function ISOWEEKNUM to return the standard ISO 8601 week number of the specified date.

I want the opposite.

➠ Given a standard week number, give me the date of the first day of that week (the Monday date).

Passing integers is acceptable. Also nice if able to pass a string in standard format.

Like this:

DATE_OF_ISOWEEKNUM( 2017 , 42 ) ➝ date of Monday of week 42 in week-based year 2017
DATE_OF_ISOWEEKNUM( "2017-W42" ) ➝ date of Monday of week 42 in week-based year 2017

Ideally, I would be able to pass a number 1-7 for Monday-Sunday to specify the day-of-week for which I want a date. Something like this:

DATE_OF_ISOWEEKNUM( 2017 , 42 , 1 ) ➝ date of Monday of week 42 in week-based year 2017
DATE_OF_ISOWEEKNUM( "2017-W42-1" ) ➝ date of Monday of week 42 in week-based year 2017

DATE_OF_ISOWEEKNUM( 2017 , 42 , 7 ) ➝ as above, but Sunday
DATE_OF_ISOWEEKNUM( "2017-W42-7" ) ➝ as above, but Sunday

回答1:


Example:

Formula:

=DATE(B$1,1,$A4*7)+(2-WEEKDAY(DATE(B$1,1,$A4*7)))-7*(ISOWEEKNUM(DATE(B$1,1,1))=1)
  • Calculate the date of day (weeknumber * 7) in the year.
  • Correct the day to be weekday Monday.
  • Correct to 7 days before, if the first day of the year is in the first ISO weeknumber.


来源:https://stackoverflow.com/questions/45392608/given-an-iso-8601-week-number-get-date-of-first-day-of-that-week-in-libreoffice

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