Results 1 to 5 of 5

Thread: [RESOLVED] VS 2017 how can i get last day of the previous month?

  1. #1

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Resolved [RESOLVED] VS 2017 how can i get last day of the previous month?

    in vb 6 i used this
    Code:
     Dim lastDayOfThePreviousMonth As Date
     lastDayOfThePreviousMonth = DateSerial(Year(Date), Month(Date), 0)
    how can i do it in vb net?
    regards
    salsa

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,929

    Re: VS 2017 how can i get last day of the previous month?

    You can use fairly similar code:
    Code:
    Dim lastDayOfThePreviousMonth As Date 
    lastDayOfThePreviousMonth = New Date(Date.Now.Year, Date.Now.Month, 1).AddDays(-1)
    ...or shortened:
    Code:
    Dim lastDayOfThePreviousMonth As Date = New Date(Date.Now.Year, Date.Now.Month, 1).AddDays(-1)

  3. #3

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: VS 2017 how can i get last day of the previous month?

    tnk you very much my friend

  4. #4
    Junior Member
    Join Date
    Jun 2010
    Location
    the Netherlands
    Posts
    18

    Re: [RESOLVED] VS 2017 how can i get last day of the previous month?

    DateSerial() also exists in VB.NET as DateAndTime.DateSerial() . It works the same way.
    English is not my native language. I trust my contributions are comprehensible. Please ask for clarification if neccessary.

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: [RESOLVED] VS 2017 how can i get last day of the previous month?

    Quote Originally Posted by raccoon View Post
    DateSerial() also exists in VB.NET as DateAndTime.DateSerial() . It works the same way.
    No reason to use VB6-holdovers unless they add some value. Very few actually do and many do the opposite.

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