View Single Post
  #1   Report Post  
Liquie Liquie is offline
Junior Member
 
Posts: 1
Default Search closest day in the past from today

From today "Sunday Feb 3rd", I want to know the closest date for "Friday" in the past. Nothing like "Sunday"-2="Friday". To be clear, I want the formula to be fixed on "Friday's" as the date progresses, so tomorrow "Monday Feb 4th", I also want to know the closest date for "Friday" in the past.

On a further step, I need a 2nd formula for the date of the 2nd "Friday" in the past, ie the Friday before the Friday.

Thank you all in advance for the help.

Edit: I think I found a solution, but I want to know, if there is a more elegant, less messy way to solve this problem:

=DATE(YEAR(TODAY()),MONTH(TODAY()),DAY(TODAY())-3-WEEKDAY(TODAY(),3)) source: http://www.excelbanter.com/showthread.php?t=259052
and
=IF(TEXT(TODAY(),"DDDD")="Monday",-3,IF(TEXT(TODAY(),"DDDD")="Tuesday",-4,IF(TEXT(TODAY(),"DDDD")="Wednesday",-5,IF(TEXT(TODAY(),"DDDD")="Thursday",-6,IF(TEXT(TODAY(),"DDDD")="Friday",0,IF(TEXT(TODAY (),"DDDD")="Saturday",-1,IF(TEXT(TODAY(),"DDDD")="Sunday",-2))))))) [Note: for the Friday before the Friday I would just increase the subtracted days ie -10,-11,-12,-13,-7,-8 and -9 respectively]
combined:
=DATE(YEAR(TODAY()),MONTH(TODAY()),DAY(TODAY())+IF (TEXT(TODAY(),"DDDD")="Monday",-3,IF(TEXT(TODAY(),"DDDD")="Tuesday",-4,IF(TEXT(TODAY(),"DDDD")="Wednesday",-5,IF(TEXT(TODAY(),"DDDD")="Thursday",-4,IF(TEXT(TODAY(),"DDDD")="Friday",0,IF(TEXT(TODAY (),"DDDD")="Saturday",-1,IF(TEXT(TODAY(),"DDDD")="Sunday",-2)))))))-WEEKDAY(TODAY(),3))


I just noticed something and have a question regarding these 4 options:

1) =DATE(YEAR(TODAY()),MONTH(TODAY()),DAY(TODAY())+7-WEEKDAY(TODAY(),3))
2) =DATE(YEAR(TODAY()),MONTH(TODAY()),DAY(TODAY())+7)
3) =TODAY()+CHOOSE(WEEKDAY(TODAY()),1,7,6,5,4,3,2)
4) =today()+7

They all give the same date, has the guy been made fun of with complicated ways of describing a simple thing? And I do not understand how "-WEEKDAY(TODAY(),3)" doesn't affect the date ie has the same outcome as option 2.

Last edited by Liquie : February 4th 13 at 12:24 AM