|
-
Oct 30th, 1999, 04:35 AM
#1
Sure thing:
Code:
Public Function GetlastDayofMonth(pDate As Date)
GetlastDayofMonth = Day(DateSerial(Year(Date), Month(Date) + 1, 0))
End Function
Usage: GetlastDayofMonth YourDate
Example:
Code:
MsgBox "This year " & Format(Date, "mmmm") & " has " & GetlastDayofMonth(Date) & " days."
Regards,
------------------
Serge
Software Developer
[email protected]
[email protected]
[This message has been edited by Serge (edited 10-30-1999).]
-
Oct 30th, 1999, 04:39 AM
#2
New Member
Yep, Serge's solution looks a lot better than mine (in the other post)....
-
Oct 30th, 1999, 04:41 AM
#3
-
Oct 30th, 1999, 06:01 AM
#4
Fanatic Member
-
Oct 30th, 1999, 11:39 AM
#5
Fanatic Member
Is there a function to determine total number of days is any month?
Thanks in advance
-
Oct 30th, 1999, 10:44 PM
#6
DiGiTaIErRoR, what IS your question then?
Regards,
------------------
Serge
Software Developer
[email protected]
[email protected]
-
Nov 11th, 1999, 04:35 PM
#7
New Member
Is'nt it supposed to be like this ? (At least)
Whats the point of sending something in to the function if you don't use it ??
Whatever you send to this function it will return the current date's last day !!??
Public Function GetlastDayofMonth(pDate As Date)
GetlastDayofMonth = Day(DateSerial(Year(pDate), Month(pDate) + 1, 0))
End Function
/Zedar
-
Nov 11th, 1999, 07:01 PM
#8
The thing is: you have to pass atleast the Month and a Year so the date can be calculated correctly. (If that's your question)
Regards,
------------------
Serge
Software Developer
[email protected]
[email protected]
ICQ#: 51055819
-
Nov 15th, 1999, 08:44 PM
#9
New Member
zedar is right.
The original code doesn't use the date variable passed to the function, but the Date function (thereby returning the number of days in the CURRENT month rather than the one in for the date specified).
HTH,
Tore.
-
Nov 15th, 1999, 09:11 PM
#10
I don't understand. In the example I made, I did passed the current date (just for testing), but the function itself is Generic. So you can pass any date.
Regards,
------------------
Serge
Software Developer
[email protected]
[email protected]
ICQ#: 51055819
-
Feb 10th, 2000, 11:28 PM
#11
New Member
Originally posted by Serge:
Sure thing:
Code:
Public Function GetlastDayofMonth(pDate As Date)
GetlastDayofMonth = Day(DateSerial(Year(Date), Month(Date) + 1, 0))
End Function
Usage: GetlastDayofMonth YourDate
Example:
Code:
MsgBox "This year " & Format(Date, "mmmm") & " has " & GetlastDayofMonth(Date) & " days."
Regards,
Serge, thanks a lot this is really useful tip, the only thing is that in your function there should be pDate used instead of date in all your calculations.
Public Function GetlastDayofMonth( _
pDate As Date)
GetlastDayofMonth = Day(DateSerial(Year(Date), Month(Date) + 1, 0))
-
Feb 11th, 2000, 12:33 PM
#12
Yep, I know I screwed up. That what happens when you type directly into the post (just a typo). LoL
------------------
Serge
Senior Programmer Analyst
[email protected]
[email protected]
ICQ#: 51055819
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|