Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
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.



  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,651
Default find date of last weekday of a month

On Sat, 28 Oct 2006 13:42:37 +0200, "Leo Heuser"
wrote:

"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


I think you can eliminate the MOD functions as WEEKDAY already effectively does
a MOD 7

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

WEEKDAY(DATE(YEAR(A1),MONTH(A1)+1,1))+1


--ron
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 266
Default find date of last weekday of a month

"Ron Rosenfeld" skrev i en meddelelse
...
On Sat, 28 Oct 2006 13:42:37 +0200, "Leo Heuser"
wrote:

"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


I think you can eliminate the MOD functions as WEEKDAY already effectively
does
a MOD 7

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

WEEKDAY(DATE(YEAR(A1),MONTH(A1)+1,1))+1


--ron


You are right. Thanks, Ron!

Leo



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
holiday dates bucci Excel Worksheet Functions 4 June 15th 06 09:35 AM
Find category value based on date range? thewiz1972 Excel Worksheet Functions 5 June 10th 06 03:28 AM
average value from a table TUNGANA KURMA RAJU Excel Discussion (Misc queries) 15 March 21st 06 06:52 AM
Get month from date [email protected] Excel Discussion (Misc queries) 2 November 9th 05 02:43 PM
Pulling a date in the current month Brian Excel Worksheet Functions 2 October 24th 05 05:57 PM


All times are GMT +1. The time now is 08:13 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"