Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 58
Default Find date of 3rd Wed of month

How can I find the date (number) of the third wednesday of a month?

Chuck
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 364
Default Find date of 3rd Wed of month

I have some code that may do what you want.

enter 1/1/2009 thru 12/1/2009 in row 1 columns A:L

then run this code:

Sub test()
Dim stdt As Long
Dim dt As Date
Dim wVal As Long
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")
For i = 1 To 12
dt = ws.Cells(1, i).Value
stdt = DatePart("w", DateSerial(Year(dt), Month(dt), 1), vbSunday,
_
vbFirstFullWeek)
If stdt = 4 Then
wVal = 21 + 1
ElseIf stdt 4 Then
wVal = 21 - (stdt - 4) + 1
Else
wVal = 14 + 4 - stdt + 1
End If
ws.Cells(2, i).Value = wVal
Next
End Sub


--


Gary K



"Chuck" wrote in message
...
How can I find the date (number) of the third wednesday of a month?

Chuck


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Find date of 3rd Wed of month

Try this formula....

=DATE(YEAR(A1),MONTH(A1),22)-WEEKDAY(DATE(YEAR(A1),MONTH(A1),4))

where A1 is assumed to contain any date within the month of interest. Of
course, you may substitute the direct year and month for both of the
YEAR(A1) and MONTH(A1) function calls.

--
Rick (MVP - Excel)


"Chuck" wrote in message
...
How can I find the date (number) of the third wednesday of a month?

Chuck


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Find date of 3rd Wed of month

I don't think this works if the 1st day of the month is a Wed.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Rick Rothstein" wrote in message
...
Try this formula....

=DATE(YEAR(A1),MONTH(A1),22)-WEEKDAY(DATE(YEAR(A1),MONTH(A1),4))

where A1 is assumed to contain any date within the month of interest. Of
course, you may substitute the direct year and month for both of the
YEAR(A1) and MONTH(A1) function calls.

--
Rick (MVP - Excel)


"Chuck" wrote in message
...
How can I find the date (number) of the third wednesday of a month?

Chuck




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Find date of 3rd Wed of month

I just tried it on a couple of April 2009 dates (April 1, 2009 is a
Wednesday) and it worked... can you show me an example month where it fails?

--
Rick (MVP - Excel)


"Bob Phillips" wrote in message
...
I don't think this works if the 1st day of the month is a Wed.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)

"Rick Rothstein" wrote in message
...
Try this formula....

=DATE(YEAR(A1),MONTH(A1),22)-WEEKDAY(DATE(YEAR(A1),MONTH(A1),4))

where A1 is assumed to contain any date within the month of interest. Of
course, you may substitute the direct year and month for both of the
YEAR(A1) and MONTH(A1) function calls.

--
Rick (MVP - Excel)


"Chuck" wrote in message
...
How can I find the date (number) of the third wednesday of a month?

Chuck







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 58
Default Find date of 3rd Wed of month

On Sun, 8 Mar 2009 09:27:30 -0400, "Rick Rothstein"
wrote:

I just tried it on a couple of April 2009 dates (April 1, 2009 is a
Wednesday) and it worked... can you show me an example month where it fails?


Thanks for the code Rick. April 1, 2009 works for me too.

Chuck
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Find date of 3rd Wed of month

Bob responded with an "oops" message. But he didn't respond to his post.

Rick Rothstein wrote:

I just tried it on a couple of April 2009 dates (April 1, 2009 is a
Wednesday) and it worked... can you show me an example month where it fails?

--
Rick (MVP - Excel)

"Bob Phillips" wrote in message
...
I don't think this works if the 1st day of the month is a Wed.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)

"Rick Rothstein" wrote in message
...
Try this formula....

=DATE(YEAR(A1),MONTH(A1),22)-WEEKDAY(DATE(YEAR(A1),MONTH(A1),4))

where A1 is assumed to contain any date within the month of interest. Of
course, you may substitute the direct year and month for both of the
YEAR(A1) and MONTH(A1) function calls.

--
Rick (MVP - Excel)


"Chuck" wrote in message
...
How can I find the date (number) of the third wednesday of a month?

Chuck




--

Dave Peterson
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Find date of 3rd Wed of month

Ah, I see his "oops" message now... I didn't associate it with this
sub-thread when I first read it.

--
Rick (MVP - Excel)


"Dave Peterson" wrote in message
...
Bob responded with an "oops" message. But he didn't respond to his post.

Rick Rothstein wrote:

I just tried it on a couple of April 2009 dates (April 1, 2009 is a
Wednesday) and it worked... can you show me an example month where it
fails?

--
Rick (MVP - Excel)

"Bob Phillips" wrote in message
...
I don't think this works if the 1st day of the month is a Wed.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)

"Rick Rothstein" wrote in message
...
Try this formula....

=DATE(YEAR(A1),MONTH(A1),22)-WEEKDAY(DATE(YEAR(A1),MONTH(A1),4))

where A1 is assumed to contain any date within the month of interest.
Of
course, you may substitute the direct year and month for both of the
YEAR(A1) and MONTH(A1) function calls.

--
Rick (MVP - Excel)


"Chuck" wrote in message
...
How can I find the date (number) of the third wednesday of a month?

Chuck




--

Dave Peterson


  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 206
Default Find date of 3rd Wed of month

Place thed 1st of the month in A2 this will give the 3rd Wednesday of
that month

=A2+MOD(4-WEEKDAY(A2),7)+14
  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Find date of 3rd Wed of month

On Sun, 08 Mar 2009 00:11:47 -0500, Chuck wrote:

How can I find the date (number) of the third wednesday of a month?

Chuck


With any date in A1,

=A1-DAY(A1)+22-WEEKDAY(A1-DAY(A1)+4)

will return the third Wednesday of that month.
--ron


  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 58
Default Find date of 3rd Wed of month

On Sun, 08 Mar 2009 00:11:47 -0500, Chuck wrote:

How can I find the date (number) of the third wednesday of a month?

Chuck


Thanks all. All equations work perfectly.

Chuck
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
Find date of first Monday of each month Ian R Excel Discussion (Misc queries) 7 June 29th 08 08:58 PM
How can I find out what date going to be 3 month from today in ex Shahin Khan Excel Worksheet Functions 5 May 8th 08 05:36 PM
find date of last weekday of a month TUNGANA KURMA RAJU Excel Discussion (Misc queries) 9 October 28th 06 02:51 PM
Date arithmetic: adding 1 month to prior end of month date manxman Excel Worksheet Functions 2 July 14th 06 09:29 PM
Sort month/date/year data using month and date only SMW820 Excel Discussion (Misc queries) 6 June 22nd 06 05:14 PM


All times are GMT +1. The time now is 10:22 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"