View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
Leo Heuser Leo Heuser is offline
external usenet poster
 
Posts: 266
Default find date of last weekday of a month

"TUNGANA KURMA RAJU" skrev i en
meddelelse ...
I need a function/formula to get date of last friday of a month.
if cell A1=10-OCT-2006 --- RESULT IN cell B1=27-OCT-2006
if cell A1=01-SEP-2006 ----RESULT IN CELL B1=29-sep-2006.


Another option:

=DATE(YEAR(A1),MONTH(A1)+1,1)-(MOD(MOD(WEEKDAY(DATE(YEAR(A1),MONTH(A1)+1,1))-1,7)+1,7)+1)

The generic formula is:

=DATE(YEAR(A1),MONTH(A1)+1,1)-(MOD(MOD(WEEKDAY(DATE(YEAR(A1),MONTH(A1)+1,1))-1,7)+X,7)+1)

If Sunday = weekday number 1:
X = 6,5,4,3,2,1,0 for last Sunday, Monday, Thuesday, Wednesday,
Thursday, Friday, Saturday
or put another way:
X = 7 - weekday number


--
Best regards
Leo Heuser

Followup to newsgroup only please.