+ Reply to Thread
Results 1 to 4 of 4

how to get month and year from date

  1. #1
    ina
    Guest

    how to get month and year from date

    Hello,

    I would like to get the begin of the next month for each month since
    one particular date until now

    Sub Time()

    Dim datFirst, dataSecond, monthnow, yearnow As Date
    Dim year, month as String

    datFirst = # 1/+month+/+Year+#

    datsecond = Now

    End sub

    If the input value is = 15/02/2006

    the result are

    01/03/2006
    01/04/2006
    01/05/2006

    I really do not know how to do it. Could someone help me please?

    Ina


  2. #2
    Bob Phillips
    Guest

    Re: how to get month and year from date

    Sub Time(InputDate)
    Dim datFirst as Date
    Dim datSecond As Date
    Dim datThird As Date

    datFirst = DateSerial(Year(InputDate),Month(InputDate)+1,1)

    datSecond = DateSerial(Year(InputDate),Month(InputDate)+2,1)

    datThird = DateSerial(Year(InputDate),Month(InputDate)+3,1)

    End Sub

    --
    HTH

    Bob Phillips

    (remove nothere from email address if mailing direct)

    "ina" <roberta.inalbon@gmail.com> wrote in message
    news:1145626946.697135.131080@i40g2000cwc.googlegroups.com...
    > Hello,
    >
    > I would like to get the begin of the next month for each month since
    > one particular date until now
    >
    > Sub Time()
    >
    > Dim datFirst, dataSecond, monthnow, yearnow As Date
    > Dim year, month as String
    >
    > datFirst = # 1/+month+/+Year+#
    >
    > datsecond = Now
    >
    > End sub
    >
    > If the input value is = 15/02/2006
    >
    > the result are
    >
    > 01/03/2006
    > 01/04/2006
    > 01/05/2006
    >
    > I really do not know how to do it. Could someone help me please?
    >
    > Ina
    >




  3. #3
    ina
    Guest

    Re: how to get month and year from date

    thank you a log but I would like to use datediff between the first date
    and and now today but I have a strange result I do not undestand why

    Do While datedifferencee > 0

    currendatemonth = Month(currentdate)
    currentdateyear = Year(currentdate)


    difference = datediff("m", todaydate, currentdate)

    datedifferencee = CInt(difference)


    currentdate = DateSerial(Year(currentdate), Month(currentdate) + i, 0)


    currendatemonth = currendatemonth + 1

    Loop

    Ina


  4. #4
    Bob Phillips
    Guest

    Re: how to get month and year from date

    Now is Date not todaydate. Also your code makes no sense to me, I am not
    seeing the link between this code and your original request. What exactly
    are you trying to do?

    --
    HTH

    Bob Phillips

    (remove nothere from email address if mailing direct)

    "ina" <roberta.inalbon@gmail.com> wrote in message
    news:1145751269.780368.43490@j33g2000cwa.googlegroups.com...
    > thank you a log but I would like to use datediff between the first date
    > and and now today but I have a strange result I do not undestand why
    >
    > Do While datedifferencee > 0
    >
    > currendatemonth = Month(currentdate)
    > currentdateyear = Year(currentdate)
    >
    >
    > difference = datediff("m", todaydate, currentdate)
    >
    > datedifferencee = CInt(difference)
    >
    >
    > currentdate = DateSerial(Year(currentdate), Month(currentdate) + i, 0)
    >
    >
    > currendatemonth = currendatemonth + 1
    >
    > Loop
    >
    > Ina
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1