Consulting

Results 1 to 2 of 2

Thread: Solved: Date + 1 year

  1. #1
    VBAX Tutor
    Joined
    Dec 2006
    Posts
    271
    Location

    Solved: Date + 1 year

    I have the following which generates a date based on the first day of a given month

    [vba]
    sDate = Me.txtStart.Value

    alwSdate = DateSerial(Year(sDate), chkMonth, 1)

    [/vba]

    I was using this to calculate the same date plus 1 year

    [vba]alwEdate = DateSerial(Year(sDate) + 1, chkMonth, 1)[/vba]

    But I actually need it to be 1 day less

    i.e.
    start 1st March 2008 the end date would be 28th Feb 2009

    so how many days are there in
    Year(sDate) +1 and chkmonth-1

    Any ideas?

  2. #2
    VBAX Tutor
    Joined
    Dec 2006
    Posts
    271
    Location
    Found it
    Changing the day to 0 seems to send it back 1 month

    [vba]alwEdate = DateSerial(Year(sDate) + 1, chkMonth, 0)[/vba]

Posting Permissions

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