Skip to main content
Solved

A formula that outputs the last Friday of the calendar year

  • August 30, 2023
  • 6 replies
  • 41 views

Forum|alt.badge.img+6

Looking for a simple formula that spits out that last Friday of the calendar year. I'm trying to avoid needing to make this a manual update so would love to find a formula that just spits that out without me having to update it at the beginning of the year. 

 

Thank you! 

Best answer by David_Skinner

DATETIME_FORMAT(YEAR(TODAY())&"-12-"&(31-MOD(WEEKDAY(YEAR(TODAY())&"-12-31")+2,7)),'MM/DD/YYYY')

6 replies

Forum|alt.badge.img+21
  • Inspiring
  • August 31, 2023

It means the last Friday in December, right?
How about a formula like this?
From a given date, find the position of Friday from the last 9 days of the year and subtract from 32 to show Friday.
{Date} would also work with "CREATED_TIME()" or "LAST_MODIFIED_TIME()".

 

DATESTR( YEAR({Date}) & "/12/" & (32 - FIND("5", WEEKDAY(DATESTR(YEAR({Date}) & "/12/31"))& WEEKDAY(DATESTR(YEAR({Date}) & "/12/30"))& WEEKDAY(DATESTR(YEAR({Date}) & "/12/29"))& WEEKDAY(DATESTR(YEAR({Date}) & "/12/28"))& WEEKDAY(DATESTR(YEAR({Date}) & "/12/27"))& WEEKDAY(DATESTR(YEAR({Date}) & "/12/26"))& WEEKDAY(DATESTR(YEAR({Date}) & "/12/25"))& WEEKDAY(DATESTR(YEAR({Date}) & "/12/24"))& WEEKDAY(DATESTR(YEAR({Date}) & "/12/23")) )) )

 

 

 

 


Forum|alt.badge.img+14

Slightly more concise than the previous answer:

DATESTR(YEAR(TODAY())&"-12-"&(31-MOD(WEEKDAY(YEAR(TODAY())&"-12-31")+2,7)))

Forum|alt.badge.img+21
  • Inspiring
  • August 31, 2023

Slightly more concise than the previous answer:

DATESTR(YEAR(TODAY())&"-12-"&(31-MOD(WEEKDAY(YEAR(TODAY())&"-12-31")+2,7)))

Excellent answer!

I now know a little bit about the use of MOD functions.


Forum|alt.badge.img+6
  • Author
  • Inspiring
  • August 31, 2023

Amazing! Thank you @Sho and @David_Skinner !

 

If I wanted to change the output to a MM/DD/YYYY format, what's the best way to do that?

Really appreciate both of your quick responses! 


Forum|alt.badge.img+14
  • Inspiring
  • Answer
  • August 31, 2023
DATETIME_FORMAT(YEAR(TODAY())&"-12-"&(31-MOD(WEEKDAY(YEAR(TODAY())&"-12-31")+2,7)),'MM/DD/YYYY')

Forum|alt.badge.img+6
  • Author
  • Inspiring
  • August 31, 2023

Thank you so much @David_Skinner !!!