|
-
Sep 10th, 2002, 01:43 AM
#1
Thread Starter
Hyperactive Member
HELP required urgently
Please help..is there any way of getting last date and the first date of a specified month.
In fact i choose the digit from a combo box i.e 1,2 so on...Now i have to get the first date and the last date of the choosen mont.
h.
if i choose 1 that is the first month..if i choose 2 i.e the second month and so on.
can anyone help.
thanks
-
Sep 10th, 2002, 02:14 AM
#2
PowerPoster
Posted bu Nucleus some time ago:
VB Code:
Private Function DaysInMonth(ByVal TheMonth As Long, ByVal TheYear As Long) As Long
DaysInMonth = Day(DateSerial(TheYear, TheMonth+1, 0))
End Function
-
Sep 10th, 2002, 04:19 AM
#3
You could add one to the month (allowing for year changes) and go to the 1st of that month then minus 1 (day) which gives you the date of the last day of the month.
A lot more code than beacons reply tho 
Do you mean the day or the date ?
VB Code:
Public Function LastDateInMonth(ByVal bytMonth As Byte, ByVal lngYear As Long) As Date
On Error Resume Next
If bytMonth > 12 Or bytMonth = 0 Then
LastDateInMonth = vbNull
Exit Function
End If
bytMonth = bytMonth + 1
If bytMonth > 12 Then
lngYear = lngYear + 1
bytMonth = bytMonth - 12
End If
LastDateInMonth = CDate("01/" & bytMonth & "/" & lngYear) - 1
End Function
Vince
Last edited by Ecniv; Sep 10th, 2002 at 04:25 AM.
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
Sep 10th, 2002, 10:17 PM
#4
Thread Starter
Hyperactive Member
Thank u very much. It served my purpose.
sid.
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
|