5 Replies - 9569 Views - Last Post: 22 July 2011 - 04:07 AM Rate Topic: -----

#1 Elda  Icon User is offline

  • D.I.C Regular

Reputation: 31
  • View blog
  • Posts: 314
  • Joined: 30-December 10

How to find last day of the month

Posted 21 July 2011 - 10:05 PM

Hello...

Anybody could please give me link on how to find last day of the month.
I googled some, but its hard for me to understand. :(
Is This A Good Question/Topic? 0
  • +

Replies To: How to find last day of the month

#2 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2241
  • View blog
  • Posts: 9,412
  • Joined: 29-May 08

Re: How to find last day of the month

Posted 21 July 2011 - 11:44 PM

What aspects of are hard?
Was This Post Helpful? 0
  • +
  • -

#3 Elda  Icon User is offline

  • D.I.C Regular

Reputation: 31
  • View blog
  • Posts: 314
  • Joined: 30-December 10

Re: How to find last day of the month

Posted 22 July 2011 - 12:30 AM

Here Sir...

Public Function GetLastDayOfMonth(intMonth, intYear) As Date

    GetLastDayOfMonth = DateSerial(intYear, intMonth + 1, 0)

End Function




To call above function
Dim datLastDay as date

datLastDay=GetLastDayOfMonth(Month(Date()),Year(Date))) 'This line got error: Date is a type and cannot be used as expression.



Do I got the closer codes?

This post has been edited by Elda: 22 July 2011 - 12:31 AM

Was This Post Helpful? 0
  • +
  • -

#4 fixo  Icon User is offline

  • D.I.C Regular

Reputation: 85
  • View blog
  • Posts: 335
  • Joined: 10-May 09

Re: How to find last day of the month

Posted 22 July 2011 - 02:09 AM

Your code is working for me, e,g.
       Dim datLastDay As Date = GetLastDayOfMonth(11, 2011)
        Console.WriteLine("{0:dd}", datLastDay)

Was This Post Helpful? 1
  • +
  • -

#5 Elda  Icon User is offline

  • D.I.C Regular

Reputation: 31
  • View blog
  • Posts: 314
  • Joined: 30-December 10

Re: How to find last day of the month

Posted 22 July 2011 - 02:17 AM

Thank you... it works now... :)
Was This Post Helpful? 0
  • +
  • -

#6 dbasnett  Icon User is offline

  • D.I.C Addict

Reputation: 108
  • View blog
  • Posts: 601
  • Joined: 01-October 08

Re: How to find last day of the month

Posted 22 July 2011 - 04:07 AM

    Private Function LastDayOfMonth(aDate As DateTime) As Date
        Return New DateTime(aDate.Year, _
                            aDate.Month, _
                            DateTime.DaysInMonth(aDate.Year, aDate.Month))
    End Function


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1