ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   maximum days in a month (https://www.excelbanter.com/excel-programming/322585-maximum-days-month.html)

James

maximum days in a month
 
hello,
What statement would I use to find out maximun days in a month in VBA?

Thanks in advance

Bernie Deitrick

maximum days in a month
 
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" wrote in message
...
hello,
What statement would I use to find out maximun days in a month in VBA?

Thanks in advance




Tom Ogilvy

maximum days in a month
 
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" wrote in message
...
hello,
What statement would I use to find out maximun days in a month in VBA?

Thanks in advance




Tom Ogilvy

maximum days in a month
 
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" wrote in message
...
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" wrote in message
...
hello,
What statement would I use to find out maximun days in a month in VBA?

Thanks in advance






sebastienm

maximum days in a month
 
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


sebastienm

maximum days in a month
 
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

Tom Ogilvy

maximum days in a month
 
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" wrote in message
...
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" wrote in message
...
hello,
What statement would I use to find out maximun days in a month in VBA?

Thanks in advance






Ron Rosenfeld

maximum days in a month
 
On Mon, 7 Feb 2005 11:05:02 -0800, "james"
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


All times are GMT +1. The time now is 11:28 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com