 |

09-12-2005, 02:52 AM
|
|
Freshman
|
|
Join Date: Aug 2005
Posts: 37
|
|
|
i wanna ask the DaysInMonth function. Is that the function return the number of days of current month ?
Code:
DaysInMonth = Day(DateSerial(Year_Number, Month_Number + 1, 0))
the Year_number and the Month_number is refer to wat date ?
|
Last edited by italkid; 09-12-2005 at 03:08 AM.
Reason: Please start your own thread if you have a question...
|

09-12-2005, 03:11 AM
|
 |
Captain Convoluted
* Expert *
|
|
Join Date: Jun 2005
Posts: 1,918
|
|
|
Yes, that is a good way of doing this.
The values Year_Number and Month_Number are just Year(Now) and Month(Now), respectively.
|
__________________
"To learn without thinking is to labour in vain" - Confucius
|

09-12-2005, 02:45 PM
|
 |
Google Hound
Retired Moderator * Guru *
|
|
Join Date: Nov 2001
Location: Arizona, USA
Posts: 12,378
|
|
If you would like to get the date of the last day of the month, you can also use the dateadd function (twice) to add 1 month to the first of the current month and then subtract 1 day from that calc.
Code:
Public Function LastOfMonth (ByRef CurrentDate as Date) as Date
LastOfMonth = DateAdd ("d", -1, DateAdd("m", 1, cDate(Month(CurrentDate) & "/1/" & Year(CurrentDate))))
End Function
Public Function DaysInMonth (ByRef CurrentDate as Date) as Integer
DaysInMonth = Day(LastOfMonth(CurrentDate))
End Function
|
__________________
Lou
"I have my standards. They may be low, but I have them!" ~ Bette Middler
"It's a book about a Spanish guy called Manual. You should read it." ~ Dilbert
"To understand recursion, you must first understand recursion." ~ unknown
Last edited by loquin; 09-13-2005 at 11:21 AM.
|

09-12-2005, 08:56 PM
|
 |
Captain Convoluted
* Expert *
|
|
Join Date: Jun 2005
Posts: 1,918
|
|
But...
Code:
DateSerial(Year(CurrentDate), Month(CurrentDate) + 1, 0))
DOES get the date of the last day of the month, and there's let casting involved since date is a numerical type... 
|
__________________
"To learn without thinking is to labour in vain" - Confucius
|

09-13-2005, 11:24 AM
|
 |
Google Hound
Retired Moderator * Guru *
|
|
Join Date: Nov 2001
Location: Arizona, USA
Posts: 12,378
|
|
|
True, dateserial IS more effecient than dateadd. I guess, more than anything else, I was pointing out an alternative method.
|
__________________
Lou
"I have my standards. They may be low, but I have them!" ~ Bette Middler
"It's a book about a Spanish guy called Manual. You should read it." ~ Dilbert
"To understand recursion, you must first understand recursion." ~ unknown
|

09-14-2005, 11:34 PM
|
|
Freshman
|
|
Join Date: Aug 2005
Posts: 37
|
|
Quote:
|
Originally Posted by TeraBlight
But...
Code:
DateSerial(Year(CurrentDate), Month(CurrentDate) + 1, 0))
DOES get the date of the last day of the month, and there's let casting involved since date is a numerical type... 
|
wat is the meaning for
Code:
Month(CurrentDate) + 1
. ?
i just wondering y wanna plus 1 there ?
thanks ! 
|
|

09-15-2005, 12:24 AM
|
|
Senior Contributor
* Expert *
|
|
Join Date: May 2004
Location: Manchester, England.
Posts: 1,254
|
|
|
if you put zero in the day parameter of the dateserial function then it returns the last day of the previous month(depending what you have in the month parameter) so if you want the current months end of month then you need to add a month.
|
|

09-15-2005, 08:14 PM
|
|
Freshman
|
|
Join Date: Aug 2005
Posts: 37
|
|
Quote:
|
Originally Posted by stevo
if you put zero in the day parameter of the dateserial function then it returns the last day of the previous month(depending what you have in the month parameter) so if you want the current months end of month then you need to add a month.
|
thanks a lot ...now i get wat i wan oredi ...thanks to all that reply my post and helped me ...
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|