Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

the first sunday of a month

1 view
Skip to first unread message

Parintas Themis STE Kardias

unread,
Aug 12, 2005, 6:12:45 AM8/12/05
to
Hi How can i have in a textbox the first sunday of a month


Rick Brandt

unread,
Aug 12, 2005, 8:52:10 AM8/12/05
to
Parintas Themis STE Kardias wrote:
> Hi How can i have in a textbox the first sunday of a month

=DateSerial(Year(Date()), Month(Date()), 1)

--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com


Wayne Morgan

unread,
Aug 12, 2005, 8:55:16 AM8/12/05
to
To get the first Sunday of the current month from today's date:

=IIf(WeekDay(DateSerial(Year(Date()), Month(Date()), 1)) = 1,
DateSerial(Year(Date()), Month(Date()), 1), DateSerial(Year(Date()),
Month(Date()), 1) - WeekDay(DateSerial(Year(Date()), Month(Date()), 1)) + 8)

--
Wayne Morgan
MS Access MVP


"Parintas Themis STE Kardias" <ste...@otenet.gr> wrote in message
news:ddhsmu$siv$1...@usenet.otenet.gr...

Rick Brandt

unread,
Aug 12, 2005, 9:00:20 AM8/12/05
to
Rick Brandt wrote:
> Parintas Themis STE Kardias wrote:
>> Hi How can i have in a textbox the first sunday of a month
>
> =DateSerial(Year(Date()), Month(Date()), 1)

DOH! sorry, Had a brain fart there. This is obviously incorrect.

Ken Snell

unread,
Aug 12, 2005, 9:41:53 AM8/12/05
to
This function should do what you seek:

Public Function DateForFixedDayOfMonthYear(Day_Year As Integer, _
Day_Month As Integer, Day_Day As Integer, Day_WeekNum As Integer) As
Date
' Day_Year is the actual year for the desired date
' Day_Month is the actual month for the desired date
' Day_Day is the number of the weekday (1 = Sunday, etc. to 7 = Saturday)
' Day_WeekNum is the ordinal value for the desired date (e.g., 1 = first, 2
= second)
'
' So, if you want the 2nd Wednesday of May 2005:
' MyDate = DateForFixedDayOfMonthYear(2005, 5, 4, 2)

DateForFixedDayOfMonthYear = DateSerial(Day_Year, Day_Month, _
8 - DatePart("w", DateSerial(Day_Year, Day_Month, 1), _
1 + Day_Day Mod 7) + (Day_WeekNum - 1) * 7)

End Function


--

Ken Snell
<MS ACCESS MVP>

"Parintas Themis STE Kardias" <ste...@otenet.gr> wrote in message
news:ddhsmu$siv$1...@usenet.otenet.gr...

jimfo...@compumarc.com

unread,
Aug 17, 2005, 6:27:51 PM8/17/05
to
Parintas Themis STE Kardias wrote:
> Hi How can i have in a textbox the first sunday of a month

I might as well throw mine in:

Public Function NthXDay(N As Integer, d As Integer, dtD As Date) As
Integer
NthXDay = (7 - WeekDay(DateSerial(Year(dtD), Month(dtD), 1)) + d) Mod 7
+ 1 + (N - 1) * 7
End Function

Usage:

To get the day of the second Saturday in September 2005:

NthXDay(2, vbSaturday, #9/1/05#)
10

James A. Fortune

0 new messages