hello,
What statement would I use to find out maximun days in a month in VBA?
Thanks in advance
hello,
What statement would I use to find out maximun days in a month in VBA?
Thanks in advance
James,
Months in VBA are the same as regular months, so 31.
But I'm guessing your question is somewhat more specific than it appears.
What kind of days? Workdays? Weekend days? Odd numbered Wednesdays?
HTH,
Bernie
MS Excel MVP
"james" <[email protected]> wrote in message
news:[email protected]...
> hello,
> What statement would I use to find out maximun days in a month in VBA?
>
> Thanks in advance
the zeroth day of the next month is the last days of the month in question
Dim dt as Date
dt = Date
lastDay = days(DateSerial(year(dt),Month(dt)+1,0))
--
Regards,
Tom Ogilvy
"james" <[email protected]> wrote in message
news:[email protected]...
> hello,
> What statement would I use to find out maximun days in a month in VBA?
>
> Thanks in advance
Here is a demo:
Sub ABCD()
sStr1 = ""
For i = 1 To 12
dt = DateSerial(2005, i, 1)
sStr = "Last day of " & _
Format(dt, "mmmm") & " is " & _
Day(DateSerial(Year(dt), Month(dt) + 1, 0))
sStr1 = sStr1 & sStr & vbNewLine
Next
MsgBox sStr1, , "Last Day of the Month for Year 2005"
End Sub
--
Regards,
Tom Ogilvy
"Tom Ogilvy" <[email protected]> wrote in message
news:[email protected]...
> the zeroth day of the next month is the last days of the month in question
>
> Dim dt as Date
> dt = Date
> lastDay = days(DateSerial(year(dt),Month(dt)+1,0))
>
> --
> Regards,
> Tom Ogilvy
>
> "james" <[email protected]> wrote in message
> news:[email protected]...
> > hello,
> > What statement would I use to find out maximun days in a month in VBA?
> >
> > Thanks in advance
>
>
Hi,
Lat day in a month i given by
Dim d as Date
d=date() '<--- your date here
'last date of month
msgbox MonthLastDay = DateSerial(Year(d), Month(d) + 1, 1 - 1)
'day number
msgbox Day(MonthLastDay = DateSerial(Year(d), Month(d) + 1, 1 - 1))
Regards,
Sebastienm
"james" wrote:
> hello,
> What statement would I use to find out maximun days in a month in VBA?
>
> Thanks in advance
okj, i'll try to re-write my previous post without error this time:
Dim d as Date
d=date() '<--- your date here
'last date of month
msgbox DateSerial(Year(d), Month(d) + 1, 1 - 1)
'day number
msgbox Day(DateSerial(Year(d), Month(d) + 1, 1 - 1))
sebastienm
Note that days should be signular
lastDay = days(DateSerial(year(dt),Month(dt)+1,0))
should be
lastDay = day(DateSerial(year(dt),Month(dt)+1,0))
sorry for the typo.
--
Regards,
Tom Ogilvy
"Tom Ogilvy" <[email protected]> wrote in message
news:[email protected]...
> the zeroth day of the next month is the last days of the month in question
>
> Dim dt as Date
> dt = Date
> lastDay = days(DateSerial(year(dt),Month(dt)+1,0))
>
> --
> Regards,
> Tom Ogilvy
>
> "james" <[email protected]> wrote in message
> news:[email protected]...
> > hello,
> > What statement would I use to find out maximun days in a month in VBA?
> >
> > Thanks in advance
>
>
On Mon, 7 Feb 2005 11:05:02 -0800, "james" <[email protected]>
wrote:
>hello,
>What statement would I use to find out maximun days in a month in VBA?
>
>Thanks in advance
You don't have to compute it since VBA uses the same calendar.
====================
Const MaxDaysInMonth As Integer = 31
====================
Perhaps you mean something else?
--ron
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks