How to use WEEKDAY function to get last Friday in Google Sheets

As I manage my stock investment portfolio in Google Sheets, I need to see its evolution over time, for example, in the last year. However, the computation for daily evolution is resource-consuming and might cause performance issues for the spreadsheet. As an alternative, I compute only the weekly evolution of the investment portfolio for the last year. For each week, I compute only the portfolio's value at the end of the Friday. For that, I need a Google Sheets formula to return the last Friday for a given date. This post explains how I do that with the WEEKDAY formula in Google Sheets.

Use WEEKDAY function in Google Sheets to find last Friday

Table of Contents

If my work has been helpful to you 🙏

Support AllStacksDeveloper blog a coffee if you find the contents useful!

Concept

To find the last Friday from a date, I need to determine how many days I need to subtract from that date.

  • If the date is Saturday, the last Friday is 1 day before it.
  • If the date is Sunday, the last Friday is 2 days before it.
  • If the date is Monday, the last Friday is 3 days before it.
  • If the date is Tuesday, the last Friday is 4 days before it.
  • If the date is Wednesday, the last Friday is 5 days before it.
  • If the date is Thursday, the last Friday is 6 days before it.
  • If the date is Friday, the last Friday is 7 days before it.

In Google Sheets, the WEEKDAY function returns a number representing the day of the week for a given date. More specifically, if the type is 2, Monday is the first day of the week, and its value is 1, while Sunday is the last day of the week, and its value is 7.

Formula and demo

Here is the final formula that can be applied on any date to find out the last Friday.

=TODAY()-IF(WEEKDAY(TODAY(),2)>5,WEEKDAY(TODAY(),2)-5,2+WEEKDAY(TODAY(),2))

Conclusion

In the next posts, I will explain how to compute the weekly evolution of a stock investment portfolio in Google Sheets. The formula to find last Friday for a given date presented in this post will be useful.

Disclaimer

The post is only for informational purposes and not for trading purposes or financial advice.

Comments

If my work has been helpful to you 🙏

Support AllStacksDeveloper blog a coffee if you find the contents useful!

Popular posts from this blog

Compute cost basis of stocks with FIFO method in Google Sheets

Create personal stock portfolio tracker with Google Sheets and Google Data Studio

Compute daily evolutions of a stock portfolio with Google Sheets and Apps Script

Use SPARKLINE to create 52-week range price indicator chart for stocks in Google Sheets

GOOGLEFINANCE Best Practices

Compute daily evolution of a stock investment portfolio by using only built-in functions of Google Sheets

Stock Portfolio Tracker Dashboard With Google Data Studio

Compute cost basis of stocks with LIFO method in Google Sheets

Manage Stock Transactions With Google Sheets