Google Spreadsheet, finding the previous weekday

后端 未结 3 460
萌比男神i
萌比男神i 2021-01-21 18:50

In Google Spreadsheet, or excel if its the same, how do I find the last weekday of day D only if D is not a weekday itself.

I.E:

If D equals weekday = do         


        
3条回答
  •  没有蜡笔的小新
    2021-01-21 19:51

    It's not so straightforward, but you can use something like that:

    =IF(OR(WEEKDAY(A1)=1,WEEKDAY(A1)=7),A1-CHOOSE(WEEKDAY(A1),2,,,,,,1),A1)
    

    Basically, if the weekday is 1 or 7 (Sunday or Saturday, as this is how Excel treats weekdays), return the date minus 2 if Sunday or minus 1 if Saturday, else the date itself.

提交回复
热议问题