Google Spreadsheet, finding the previous weekday

后端 未结 3 431
萌比男神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:42

    Another option may be:

    =IF(WEEKDAY(D1, 2) > 5, D1 - (WEEKDAY(D1, 2) - 5), D1)
    
    0 讨论(0)
  • 2021-01-21 19:45
    =WORKDAY("2013-04-06"+1, -1)
    

    ...does the trick.

    0 讨论(0)
  • 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.

    0 讨论(0)
提交回复
热议问题