Results 1 to 4 of 4

Thread: HELP required urgently

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Malaysia
    Posts
    345

    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
    Thanks.

  2. #2
    PowerPoster Beacon's Avatar
    Join Date
    Jan 2001
    Location
    Pub Floor
    Posts
    3,188
    Posted bu Nucleus some time ago:

    VB Code:
    1. Private Function DaysInMonth(ByVal TheMonth As Long, ByVal TheYear As Long) As Long
    2.     DaysInMonth = Day(DateSerial(TheYear, TheMonth+1, 0))
    3. End Function

  3. #3
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343
    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:
    1. Public Function LastDateInMonth(ByVal bytMonth As Byte, ByVal lngYear As Long) As Date
    2.     On Error Resume Next
    3.    
    4.     If bytMonth > 12 Or bytMonth = 0 Then
    5.         LastDateInMonth = vbNull
    6.         Exit Function
    7.     End If
    8.    
    9.    
    10.     bytMonth = bytMonth + 1
    11.     If bytMonth > 12 Then
    12.         lngYear = lngYear + 1
    13.         bytMonth = bytMonth - 12
    14.     End If
    15.     LastDateInMonth = CDate("01/" & bytMonth & "/" & lngYear) - 1
    16. End Function

    Vince
    Last edited by Ecniv; Sep 10th, 2002 at 04:25 AM.

    BOFH Now, BOFH Past, Information on duplicates

    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...

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Malaysia
    Posts
    345
    Thank u very much. It served my purpose.

    sid.
    Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width